[A Starter Template]
- Good ol' Express.
- Type-safety (TypeScript).
- ORM with migration, factory, query builder (Objection + Knex).
- Session-based and Token-based Authentication (Passport).
- Templating (EJS).
- Utility-first CSS framework (Tailwind [via CDN]).
- Logging (Winston + Morgan).
- Testing (Supertest + Mocha + Chai).
- Mailing (Nodemailer).
- Request validation (Express Validator).
- Background job processing (Bull).
- Queue monitoring dashboard (Bull Board).
- Generate a project based on this template.
- Clone the newly created repo and
cd
into the directory. - Run
cp .env.example .env
to create a .env file based on the example file and provide all the necessary information. - Run
npm run install
or,yarn install
if you're using yarn. - Run
npm run dev
or,yarn dev
.
npm run build
: Compile all .ts source files and output the compiled files into /dist directory.npm run dev
: Run the project in development mode. Changes will be picked up and server will be restarted automatically.npm run test
: Run all the unit and integration tests located in /tests directory.npm run start
: Compile the .ts source files and run the project by invoking the compiled source files.npm run fmt
: Format the source code using the rules defined in .prettierrc.npm run migrate:make
: Create a migration file. Ex:npm run migrate:make create_users_table
. A migration file with current timestamp will be created inside the /src/database/migrations directory.npm run migrate:latest
: Migrate the database schema. This will apply all newly created migrations.npm run migrate:rollback
: Undo the last run migration.- To run more migration or seed-specific commands, consider installing the knex cli globally. Learn more.
The project ships with some docker configs and a cli
. You can interact with the docker containers using this cli. When the NODE_ENV
variable is set to production
, the cli will use the docker-compose.yml
and docker-compose.prod.yml
file, otherwise it will use the docker-compose.yml
and docker-compose.dev.yml
file.
./cli start
to launch all the containers in detached mode../cli stop
will stop and remove all the containers../cli yarn
will invoke theyarn
command from within theapp
container. For example, to compile the source code, you could run./cli yarn build
.- When running in production, you might want to use a free SSL from LetsEncrypt.
./cli ssl
will attempt to issue a certificate for the domains you've specified in your.env
file. TheSSL_STAGING=1
generates a dummy certificate, andSSL_STAGING=0
generates a real certificate and you will face an ACME challenge. Make sure your DNS record panel is open in another tab before you proceed with this operation. If the ACME challenge fails, try again with./cli ssl
. - If the certificate has been generated successfully, you will need to run
./cli post-ssl
to fetch the dhparam key file. - Adjust the production specific nginx configs in the
nginx.prod.conf
file.
- Template engine and view layer. [Done]
- Allow swapping between NoSQL and RDBMSes.
- Cookie-based authentication. [Done]
- Unified database pagination. [Done]
- Simplified file uploader.
- Add seeders and seeder commands.
Do you have a significant feature in mind? Create an issue or send a pull request.
- Although this template comes with many components pre-installed, it does not impose any hard-bound rule on the project structure. Feel free to customize the directory structure and add or remove the components as you see fit for your project. Removing a module will be easier since we're using TypeScript. Any good text editor/IDE will help you track down a non-existing reference in the codebase.
- Kebab-case is used for the file names since it is the most compatible across all operating systems. If you don't like this convention, feel free to change.