A NextJS-Thirdweb webkit with inspiration drawn from Laravel
- The directory structure and certain features of this webkit was inspired by Laravel
- The main goal of this project was to make it easier for developers when working with a Laravel Project and a NextJS at the same time
- there are useful scripts in
package.jsonthat can aid in development - run
yarn scriptsto show available scripts
yarn setup- run migrations and seed prerequisite and test data
- Certain libraries like models can be generated through the
makecommand. yarn make:help- shows available template commands and description
- For example:
yarn make:model user- create a user
model,seeder,factoryand inserts a new table/model inschema.prisma
- create a user
yarn make:crud user- Generates all initially needed libraries for creating a RESTFUL API
- initiates
make:controller,make:model, andmake:api
yarn prisma:generate- update prisma client with the latest changes in the schema
- please run this after updating the schema to avoid type errors when using models
yarn migrate:dev- run database migrations and seed (updating database with changes in schema)
yarn migrate:reset- reset database schema and seed
yarn db:seed- run/rerun seeders
src- all the application related code.
config- application configs that includes the constants
databasefactories- code for generating test models ideally with fakerjs
seeders- code for seeding database with test or production data
proddev
- code for seeding database with test or production data
migrations- sql files generated by prisma, can be edited manually for custom changes
libraryhooks- set of hooks to be used in frontend
enums- set of constants like GUARDS for list of guard constants
helpers- library that is specific to the project like guard or http helper
utils- generic reusable piece of code that can be used anywhere like randomColor()
httpcontrollers- for interacting with services and returning data requested by the app
requests- form data or query validations, all data validators per controller exists here
models- for database queries
errors- custom error classes
resourcescss- contains all the stylesheets
components- contains the layout files and reusable components
stores- responsible for fetching data from the api and formatting them and storing to local storage
pages: for pages routerapi: api endpoints
tests- directory for all automated tests
jestcypress
- Components should be in
PascalCase - Route and directory names should be in
kebab-case - Other files should be in
camelCase
- Models:
[name].model.ts(e.g.user.model.ts) - Controllers:
[name].controller.ts(e.g.auth.controller.ts) - Requests:
[name].request.ts(e.g.auth.request.ts) - Tests:
[name].test.tsor[name.category].test.tsif applicable (e.g.auth.test.ts) - Seeders:
[name].seeder.ts(e.g.user.seeder.ts) - Factory:
[name].factory.ts(e.g.user.factory.ts)
- Please use request objects for validations (create validator objects in
src/library/http/requests). It makes use of the zod package for the rules