-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also run deno fmt, and reorganize it into a chiselc directory
- Loading branch information
1 parent
875df86
commit ab34a2e
Showing
16 changed files
with
133 additions
and
33 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 3 additions & 1 deletion
4
perf/backend/endpoints/bench.ts → perf/chiselc/backend/endpoints/bench.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { User } from "../models/user"; | ||
|
||
export default async function (req: Request): Promise<Response> { | ||
const user = await User.findOne(user => user.name == "Glauber Costa" && user.age >= 40); | ||
const user = await User.findOne((user) => | ||
user.name == "Glauber Costa" && user.age >= 40 | ||
); | ||
return new Response(user?.email ?? "not found"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { User } from "../models/user"; | ||
import { validate } from "email-validator"; | ||
|
||
export default async function (req: Request): Promise<Response> { | ||
const user = await User.findOne((user) => | ||
user.name == "Glauber Costa" && user.age >= 40 | ||
); | ||
return new Response(validate(user?.email) ? user.email : "not found"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { faker } from "@faker-js/faker"; | ||
|
||
import { User } from "../models/user"; | ||
|
||
function randomInt(min: number, max: number) { | ||
min = Math.ceil(min); | ||
max = Math.floor(max); | ||
return Math.floor(Math.random() * (max - min + 1)) + min; | ||
} | ||
|
||
// call fixture/<number> to generate <number> entries | ||
export default async function (req: ChiselRequest): Promise<Response> { | ||
const rr = req.pathParams; | ||
const parsed = parseInt(req.pathParams); | ||
const populationSize = isNaN(parsed) ? 0 : parsed; | ||
|
||
const glauberPos = randomInt(0, populationSize); | ||
const glauberJrPos = randomInt(0, populationSize); | ||
|
||
const promises = []; | ||
for (let i = 0; i < populationSize; i++) { | ||
promises.push(User.create({ | ||
name: faker.name.findName(), | ||
email: faker.internet.email(), | ||
age: randomInt(0, 100), | ||
})); | ||
|
||
if (i % 1000 == 0) { | ||
await Promise.all(promises); | ||
promises.length = 0; | ||
} | ||
|
||
if (i == glauberPos) { | ||
promises.push(User.create({ | ||
name: "Glauber Costa", | ||
email: "glauber@nospam.me", | ||
age: 40, | ||
})); | ||
} | ||
if (i == glauberJrPos) { | ||
promises.push(User.create({ | ||
name: "Glauber Costa", | ||
email: "glauberjr@nospam.me", | ||
age: 15, | ||
})); | ||
} | ||
} | ||
await Promise.all(promises); | ||
return new Response(`inserted ${populationSize}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { User } from "../models/user"; | ||
import { validate } from "email-validator"; | ||
|
||
export default async function (req: Request): Promise<Response> { | ||
const user = await User.findOne((user) => | ||
user.name == "Glauber Costa" && user.age >= 40 && validate(user.email) | ||
); | ||
return new Response(user?.email ?? "not found"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { User } from "../models/user"; | ||
|
||
export default async function (req: Request): Promise<Response> { | ||
await User.create({ | ||
name: "Glauber Costa", | ||
email: "glauber@nospam.me", | ||
age: 40, | ||
}); | ||
await User.create({ | ||
name: "Glauber Costa", | ||
email: "glauberjr@nospam.me", | ||
age: 15, | ||
}); | ||
return new Response("ok"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { User } from "../models/user.ts"; | ||
|
||
export default User.crud(); |
2 changes: 1 addition & 1 deletion
2
perf/backend/models/user.ts → perf/chiselc/backend/models/user.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 23 additions & 7 deletions
30
perf/backend/package-lock.json → perf/chiselc/backend/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.