-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: crud task according to workflow #19
Changes from all commits
4bf50ea
3cdc624
3e0bc10
f17f4ef
345353e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,12 @@ | |
"test": "test" | ||
}, | ||
"scripts": { | ||
"build": "rm -rf dist && tsc", | ||
"watch": "npm run build -- --watch", | ||
"start": "npm run build && fastify start -l info dist/app.js", | ||
"build": "tsc", | ||
"watch": "tsc -w", | ||
"dev": "npm run build && concurrently -k -p \"[{name}]\" -n \"TypeScript,App\" -c \"yellow.bold,cyan.bold\" \"npm:watch\" \"npm:dev:start\"", | ||
"dev:start": "fastify start --ignore-watch=.ts$ -w -l info -P dist/app.js", | ||
Comment on lines
+11
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve the dev mode experience. Inspired by: https://github.com/fastify/fastify-cli/blob/master/generate.js#L54 |
||
"test": "npm run db:seed && tap --jobs=1 test/**/*", | ||
"start": "fastify start -l info dist/app.js", | ||
"dev": "fastify start -w -l info -P dist/app.js", | ||
"standalone": "node --env-file=.env dist/server.js", | ||
"lint": "eslint --ignore-pattern=dist", | ||
"lint:fix": "npm run lint -- --fix", | ||
|
@@ -36,6 +37,7 @@ | |
"@fastify/type-provider-typebox": "^4.0.0", | ||
"@fastify/under-pressure": "^8.3.0", | ||
"@sinclair/typebox": "^0.33.7", | ||
"concurrently": "^8.2.2", | ||
"fastify": "^4.26.1", | ||
"fastify-cli": "^6.1.1", | ||
"fastify-plugin": "^4.0.0", | ||
|
@@ -47,7 +49,7 @@ | |
"fastify-tsconfig": "^2.0.0", | ||
"mysql2": "^3.10.1", | ||
"neostandard": "^0.7.0", | ||
"tap": "^19.2.2", | ||
"tap": "^21.0.1", | ||
"typescript": "^5.4.5" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,20 @@ import path from "node:path"; | |
import fastifyAutoload from "@fastify/autoload"; | ||
import { FastifyInstance, FastifyPluginOptions } from "fastify"; | ||
|
||
export const options = { | ||
ajv: { | ||
customOptions: { | ||
coerceTypes: "array", | ||
removeAdditional: "all" | ||
} | ||
} | ||
}; | ||
|
||
export default async function serviceApp( | ||
fastify: FastifyInstance, | ||
opts: FastifyPluginOptions | ||
) { | ||
delete opts.skipOverride // This option only serves testing purpose | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I feared, I think we've introduced a problem here: https://github.com/fastify/fastify-cli/pull/742/files#r1689541348 For example,
Maybe it's also a bad design to propagate all the options in the autoloader? Like the cli generated template suggest to do: export default async function serviceApp(
fastify: FastifyInstance,
opts: FastifyPluginOptions
) {
await fastify.register(fastifyAutoload, {
dir: path.join(import.meta.dirname, "plugins"),
options: { ...opts } // opts propagated here
});
// code...
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what to say here, but you are right. Passing all default options that results into this error, is NOT good. |
||
// This loads all external plugins defined in plugins/external | ||
// those should be registered first as your custom plugins might depend on them | ||
await fastify.register(fastifyAutoload, { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,36 @@ | ||
import { Type } from "@sinclair/typebox"; | ||
import { Static, Type } from "@sinclair/typebox"; | ||
|
||
export const TaskStatus = { | ||
New: 'new', | ||
InProgress: 'in-progress', | ||
OnHold: 'on-hold', | ||
Completed: 'completed', | ||
Canceled: 'canceled', | ||
Archived: 'archived' | ||
} as const; | ||
|
||
export type TaskStatusType = typeof TaskStatus[keyof typeof TaskStatus]; | ||
|
||
export const TaskSchema = Type.Object({ | ||
id: Type.Number(), | ||
name: Type.String() | ||
name: Type.String(), | ||
author_id: Type.Number(), | ||
assigned_user_id: Type.Optional(Type.Number()), | ||
status: Type.String(), | ||
created_at: Type.String({ format: "date-time" }), | ||
updated_at: Type.String({ format: "date-time" }) | ||
}); | ||
|
||
export interface Task extends Static<typeof TaskSchema> {} | ||
|
||
export const CreateTaskSchema = Type.Object({ | ||
name: Type.String(), | ||
author_id: Type.Number(), | ||
assigned_user_id: Type.Optional(Type.Number()) | ||
}); | ||
|
||
export const UpdateTaskSchema = Type.Object({ | ||
name: Type.Optional(Type.String()), | ||
assigned_user_id: Type.Optional(Type.Number()) | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is watch not working or?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does work, but will people use it now that we run it concurrently with the dev server?