Skip to content

Commit db49128

Browse files
committed
I think the exercises are done
1 parent 3348cf6 commit db49128

File tree

114 files changed

+4679
-2831
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+4679
-2831
lines changed

epicshop/mcp-dev/dev.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ const [, , ...args] = process.argv
1212
const [transport] = args
1313

1414
const serverPort = await getPort({
15-
port: 10000,
15+
port: Array.from({ length: 1000 }, (_, i) => i + 10000),
1616
exclude: [process.env.PORT].filter(Boolean).map(Number),
1717
})
1818
const clientPort = await getPort({
19-
port: 9000,
19+
port: Array.from({ length: 1000 }, (_, i) => i + 9000),
2020
exclude: [process.env.PORT, serverPort].filter(Boolean).map(Number),
2121
})
2222

@@ -72,6 +72,8 @@ const server = createServer((req, res) => {
7272
'MCP_PROXY_FULL_ADDRESS',
7373
`http://localhost:${serverPort}`,
7474
)
75+
url.searchParams.set('MCP_REQUEST_MAX_TOTAL_TIMEOUT', 1000 * 60 * 15)
76+
url.searchParams.set('MCP_SERVER_REQUEST_TIMEOUT', 1000 * 60 * 5)
7577
const correctedUrl = url.pathname + url.search
7678
if (correctedUrl !== req.url) {
7779
res.writeHead(302, { Location: correctedUrl })

exercises/03.advanced-tools/01.problem.db/src/db/index.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,42 +71,6 @@ export class DB {
7171
return z.array(entrySchema).parse(entries)
7272
}
7373

74-
async getEntriesWithTags() {
75-
const entriesStmt = this.#db.prepare(
76-
sql`SELECT * FROM entries ORDER BY created_at DESC`,
77-
)
78-
const entries = entriesStmt.all().map((entry) => snakeToCamel(entry))
79-
80-
// Query all tags for all entries
81-
const tagsStmt = this.#db.prepare(sql`
82-
SELECT et.entry_id, t.id as tag_id, t.name as tag_name
83-
FROM entry_tags et
84-
JOIN tags t ON et.tag_id = t.id
85-
`)
86-
const tagRows = tagsStmt.all().map((row) => snakeToCamel(row))
87-
88-
// Build a map of entryId to tags
89-
const entryIdToTags = new Map<number, Array<{ id: number; name: string }>>()
90-
for (const row of tagRows as any[]) {
91-
const { entryId, tagId, tagName } = row
92-
if (!entryIdToTags.has(entryId)) {
93-
entryIdToTags.set(entryId, [])
94-
}
95-
entryIdToTags.get(entryId)!.push({ id: tagId, name: tagName })
96-
}
97-
98-
const entryWithTagSchema = entrySchema.extend({
99-
tags: z.array(z.object({ id: z.number(), name: z.string() })),
100-
})
101-
102-
const entriesWithTags = entries.map((entry: any) => ({
103-
...entry,
104-
tags: entryIdToTags.get(entry.id) ?? [],
105-
}))
106-
107-
return z.array(entryWithTagSchema).parse(entriesWithTags)
108-
}
109-
11074
async getEntry(id: number) {
11175
const stmt = this.#db.prepare(sql`SELECT * FROM entries WHERE id = ?`)
11276
const entryResult = stmt.get(id)

exercises/03.advanced-tools/01.solution.db/src/db/index.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,42 +71,6 @@ export class DB {
7171
return z.array(entrySchema).parse(entries)
7272
}
7373

74-
async getEntriesWithTags() {
75-
const entriesStmt = this.#db.prepare(
76-
sql`SELECT * FROM entries ORDER BY created_at DESC`,
77-
)
78-
const entries = entriesStmt.all().map((entry) => snakeToCamel(entry))
79-
80-
// Query all tags for all entries
81-
const tagsStmt = this.#db.prepare(sql`
82-
SELECT et.entry_id, t.id as tag_id, t.name as tag_name
83-
FROM entry_tags et
84-
JOIN tags t ON et.tag_id = t.id
85-
`)
86-
const tagRows = tagsStmt.all().map((row) => snakeToCamel(row))
87-
88-
// Build a map of entryId to tags
89-
const entryIdToTags = new Map<number, Array<{ id: number; name: string }>>()
90-
for (const row of tagRows as any[]) {
91-
const { entryId, tagId, tagName } = row
92-
if (!entryIdToTags.has(entryId)) {
93-
entryIdToTags.set(entryId, [])
94-
}
95-
entryIdToTags.get(entryId)!.push({ id: tagId, name: tagName })
96-
}
97-
98-
const entryWithTagSchema = entrySchema.extend({
99-
tags: z.array(z.object({ id: z.number(), name: z.string() })),
100-
})
101-
102-
const entriesWithTags = entries.map((entry: any) => ({
103-
...entry,
104-
tags: entryIdToTags.get(entry.id) ?? [],
105-
}))
106-
107-
return z.array(entryWithTagSchema).parse(entriesWithTags)
108-
}
109-
11074
async getEntry(id: number) {
11175
const stmt = this.#db.prepare(sql`SELECT * FROM entries WHERE id = ?`)
11276
const entryResult = stmt.get(id)

exercises/03.advanced-tools/02.problem.organization/src/db/index.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,42 +71,6 @@ export class DB {
7171
return z.array(entrySchema).parse(entries)
7272
}
7373

74-
async getEntriesWithTags() {
75-
const entriesStmt = this.#db.prepare(
76-
sql`SELECT * FROM entries ORDER BY created_at DESC`,
77-
)
78-
const entries = entriesStmt.all().map((entry) => snakeToCamel(entry))
79-
80-
// Query all tags for all entries
81-
const tagsStmt = this.#db.prepare(sql`
82-
SELECT et.entry_id, t.id as tag_id, t.name as tag_name
83-
FROM entry_tags et
84-
JOIN tags t ON et.tag_id = t.id
85-
`)
86-
const tagRows = tagsStmt.all().map((row) => snakeToCamel(row))
87-
88-
// Build a map of entryId to tags
89-
const entryIdToTags = new Map<number, Array<{ id: number; name: string }>>()
90-
for (const row of tagRows as any[]) {
91-
const { entryId, tagId, tagName } = row
92-
if (!entryIdToTags.has(entryId)) {
93-
entryIdToTags.set(entryId, [])
94-
}
95-
entryIdToTags.get(entryId)!.push({ id: tagId, name: tagName })
96-
}
97-
98-
const entryWithTagSchema = entrySchema.extend({
99-
tags: z.array(z.object({ id: z.number(), name: z.string() })),
100-
})
101-
102-
const entriesWithTags = entries.map((entry: any) => ({
103-
...entry,
104-
tags: entryIdToTags.get(entry.id) ?? [],
105-
}))
106-
107-
return z.array(entryWithTagSchema).parse(entriesWithTags)
108-
}
109-
11074
async getEntry(id: number) {
11175
const stmt = this.#db.prepare(sql`SELECT * FROM entries WHERE id = ?`)
11276
const entryResult = stmt.get(id)

exercises/03.advanced-tools/02.solution.organization/src/db/index.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,42 +71,6 @@ export class DB {
7171
return z.array(entrySchema).parse(entries)
7272
}
7373

74-
async getEntriesWithTags() {
75-
const entriesStmt = this.#db.prepare(
76-
sql`SELECT * FROM entries ORDER BY created_at DESC`,
77-
)
78-
const entries = entriesStmt.all().map((entry) => snakeToCamel(entry))
79-
80-
// Query all tags for all entries
81-
const tagsStmt = this.#db.prepare(sql`
82-
SELECT et.entry_id, t.id as tag_id, t.name as tag_name
83-
FROM entry_tags et
84-
JOIN tags t ON et.tag_id = t.id
85-
`)
86-
const tagRows = tagsStmt.all().map((row) => snakeToCamel(row))
87-
88-
// Build a map of entryId to tags
89-
const entryIdToTags = new Map<number, Array<{ id: number; name: string }>>()
90-
for (const row of tagRows as any[]) {
91-
const { entryId, tagId, tagName } = row
92-
if (!entryIdToTags.has(entryId)) {
93-
entryIdToTags.set(entryId, [])
94-
}
95-
entryIdToTags.get(entryId)!.push({ id: tagId, name: tagName })
96-
}
97-
98-
const entryWithTagSchema = entrySchema.extend({
99-
tags: z.array(z.object({ id: z.number(), name: z.string() })),
100-
})
101-
102-
const entriesWithTags = entries.map((entry: any) => ({
103-
...entry,
104-
tags: entryIdToTags.get(entry.id) ?? [],
105-
}))
106-
107-
return z.array(entryWithTagSchema).parse(entriesWithTags)
108-
}
109-
11074
async getEntry(id: number) {
11175
const stmt = this.#db.prepare(sql`SELECT * FROM entries WHERE id = ?`)
11276
const entryResult = stmt.get(id)

exercises/03.advanced-tools/03.problem.class/src/db/index.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,42 +71,6 @@ export class DB {
7171
return z.array(entrySchema).parse(entries)
7272
}
7373

74-
async getEntriesWithTags() {
75-
const entriesStmt = this.#db.prepare(
76-
sql`SELECT * FROM entries ORDER BY created_at DESC`,
77-
)
78-
const entries = entriesStmt.all().map((entry) => snakeToCamel(entry))
79-
80-
// Query all tags for all entries
81-
const tagsStmt = this.#db.prepare(sql`
82-
SELECT et.entry_id, t.id as tag_id, t.name as tag_name
83-
FROM entry_tags et
84-
JOIN tags t ON et.tag_id = t.id
85-
`)
86-
const tagRows = tagsStmt.all().map((row) => snakeToCamel(row))
87-
88-
// Build a map of entryId to tags
89-
const entryIdToTags = new Map<number, Array<{ id: number; name: string }>>()
90-
for (const row of tagRows as any[]) {
91-
const { entryId, tagId, tagName } = row
92-
if (!entryIdToTags.has(entryId)) {
93-
entryIdToTags.set(entryId, [])
94-
}
95-
entryIdToTags.get(entryId)!.push({ id: tagId, name: tagName })
96-
}
97-
98-
const entryWithTagSchema = entrySchema.extend({
99-
tags: z.array(z.object({ id: z.number(), name: z.string() })),
100-
})
101-
102-
const entriesWithTags = entries.map((entry: any) => ({
103-
...entry,
104-
tags: entryIdToTags.get(entry.id) ?? [],
105-
}))
106-
107-
return z.array(entryWithTagSchema).parse(entriesWithTags)
108-
}
109-
11074
async getEntry(id: number) {
11175
const stmt = this.#db.prepare(sql`SELECT * FROM entries WHERE id = ?`)
11276
const entryResult = stmt.get(id)

exercises/03.advanced-tools/03.solution.class/src/db/index.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,42 +71,6 @@ export class DB {
7171
return z.array(entrySchema).parse(entries)
7272
}
7373

74-
async getEntriesWithTags() {
75-
const entriesStmt = this.#db.prepare(
76-
sql`SELECT * FROM entries ORDER BY created_at DESC`,
77-
)
78-
const entries = entriesStmt.all().map((entry) => snakeToCamel(entry))
79-
80-
// Query all tags for all entries
81-
const tagsStmt = this.#db.prepare(sql`
82-
SELECT et.entry_id, t.id as tag_id, t.name as tag_name
83-
FROM entry_tags et
84-
JOIN tags t ON et.tag_id = t.id
85-
`)
86-
const tagRows = tagsStmt.all().map((row) => snakeToCamel(row))
87-
88-
// Build a map of entryId to tags
89-
const entryIdToTags = new Map<number, Array<{ id: number; name: string }>>()
90-
for (const row of tagRows as any[]) {
91-
const { entryId, tagId, tagName } = row
92-
if (!entryIdToTags.has(entryId)) {
93-
entryIdToTags.set(entryId, [])
94-
}
95-
entryIdToTags.get(entryId)!.push({ id: tagId, name: tagName })
96-
}
97-
98-
const entryWithTagSchema = entrySchema.extend({
99-
tags: z.array(z.object({ id: z.number(), name: z.string() })),
100-
})
101-
102-
const entriesWithTags = entries.map((entry: any) => ({
103-
...entry,
104-
tags: entryIdToTags.get(entry.id) ?? [],
105-
}))
106-
107-
return z.array(entryWithTagSchema).parse(entriesWithTags)
108-
}
109-
11074
async getEntry(id: number) {
11175
const stmt = this.#db.prepare(sql`SELECT * FROM entries WHERE id = ?`)
11276
const entryResult = stmt.get(id)

exercises/04.resources/01.problem.simple/src/db/index.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,42 +71,6 @@ export class DB {
7171
return z.array(entrySchema).parse(entries)
7272
}
7373

74-
async getEntriesWithTags() {
75-
const entriesStmt = this.#db.prepare(
76-
sql`SELECT * FROM entries ORDER BY created_at DESC`,
77-
)
78-
const entries = entriesStmt.all().map((entry) => snakeToCamel(entry))
79-
80-
// Query all tags for all entries
81-
const tagsStmt = this.#db.prepare(sql`
82-
SELECT et.entry_id, t.id as tag_id, t.name as tag_name
83-
FROM entry_tags et
84-
JOIN tags t ON et.tag_id = t.id
85-
`)
86-
const tagRows = tagsStmt.all().map((row) => snakeToCamel(row))
87-
88-
// Build a map of entryId to tags
89-
const entryIdToTags = new Map<number, Array<{ id: number; name: string }>>()
90-
for (const row of tagRows as any[]) {
91-
const { entryId, tagId, tagName } = row
92-
if (!entryIdToTags.has(entryId)) {
93-
entryIdToTags.set(entryId, [])
94-
}
95-
entryIdToTags.get(entryId)!.push({ id: tagId, name: tagName })
96-
}
97-
98-
const entryWithTagSchema = entrySchema.extend({
99-
tags: z.array(z.object({ id: z.number(), name: z.string() })),
100-
})
101-
102-
const entriesWithTags = entries.map((entry: any) => ({
103-
...entry,
104-
tags: entryIdToTags.get(entry.id) ?? [],
105-
}))
106-
107-
return z.array(entryWithTagSchema).parse(entriesWithTags)
108-
}
109-
11074
async getEntry(id: number) {
11175
const stmt = this.#db.prepare(sql`SELECT * FROM entries WHERE id = ?`)
11276
const entryResult = stmt.get(id)

exercises/04.resources/01.solution.simple/src/db/index.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,42 +71,6 @@ export class DB {
7171
return z.array(entrySchema).parse(entries)
7272
}
7373

74-
async getEntriesWithTags() {
75-
const entriesStmt = this.#db.prepare(
76-
sql`SELECT * FROM entries ORDER BY created_at DESC`,
77-
)
78-
const entries = entriesStmt.all().map((entry) => snakeToCamel(entry))
79-
80-
// Query all tags for all entries
81-
const tagsStmt = this.#db.prepare(sql`
82-
SELECT et.entry_id, t.id as tag_id, t.name as tag_name
83-
FROM entry_tags et
84-
JOIN tags t ON et.tag_id = t.id
85-
`)
86-
const tagRows = tagsStmt.all().map((row) => snakeToCamel(row))
87-
88-
// Build a map of entryId to tags
89-
const entryIdToTags = new Map<number, Array<{ id: number; name: string }>>()
90-
for (const row of tagRows as any[]) {
91-
const { entryId, tagId, tagName } = row
92-
if (!entryIdToTags.has(entryId)) {
93-
entryIdToTags.set(entryId, [])
94-
}
95-
entryIdToTags.get(entryId)!.push({ id: tagId, name: tagName })
96-
}
97-
98-
const entryWithTagSchema = entrySchema.extend({
99-
tags: z.array(z.object({ id: z.number(), name: z.string() })),
100-
})
101-
102-
const entriesWithTags = entries.map((entry: any) => ({
103-
...entry,
104-
tags: entryIdToTags.get(entry.id) ?? [],
105-
}))
106-
107-
return z.array(entryWithTagSchema).parse(entriesWithTags)
108-
}
109-
11074
async getEntry(id: number) {
11175
const stmt = this.#db.prepare(sql`SELECT * FROM entries WHERE id = ?`)
11276
const entryResult = stmt.get(id)

0 commit comments

Comments
 (0)