My personnal starter for fastify project.
- fastify
- knex
- objection
- i18n
- @exodus/schemasafe
- role-acl
- bcryptjs
- jwt
- lorenwest/node-config
- codeBelt/generate-template-files
- nodemailer
requires Node.js to run.
Clone, install the dependencies and devDependencies and start the server.
$ npm install
Generate your first service (example restaurant)
$ npm run generate
Create Model -> restaurant -> Output path: ./app/models/
Create Service -> restaurant -> Output path: ./app/services/restaurant
Create Migration -> restaurant -> Output path: ./database/migrations/restaurant.js
Create Seed -> restaurant -> Output path: ./database/seeds/restaurant.js
$ npm run db:reset
Add your service in server.js
fastify.register(require("./services/restaurant"));
Launch the server
$ npm run dev
Urls :
GET http://localhost:3030/api/restaurant/
GET http://localhost:3030/api/restaurant/1
POST http://localhost:3030/api/restaurant/ (with body json {name:"foo"} )
PUT http://localhost:3030/api/restaurant/ (with body json {id:1,name:"foo correct"} )
DELETE http://localhost:3030/api/restaurant/1
Others :
POST http://localhost:3030/api/auth/login (with body json {email:"[email protected]","password":"demo"} )
POST http://localhost:3030/api/auth/register (with body json {email:"[email protected]","password":"demo"} )
GET http://localhost:3030/api/auth/me (with Bearer )
GET http://localhost:3030/api/user/ (superadmin permission)
GET http://localhost:3030/api/user/1 (superadmin permission)
POST http://localhost:3030/api/user/ (with body json {email:"foo", password:"", etc...} ) (superadmin permission)
PUT http://localhost:3030/api/user/ (with body json {id:1,foo1:"foo",foo2:"foo2"}) (superadmin permission)
DELETE http://localhost:3030/api/user/1 (superadmin permission)
Insomnia export in "tools" for tests
In progress :
Permissions/Groups/Roles
Email verification option