🧰 An awesome kickstart server with all the features you would expect, for Node + Typescript + Koa development.
- Simplicity and flexibility.
- Typescript out-of-box.
- Path aliases to clean up noisy paths, see more explanation.
- Tiny and robust web framework, Koa.
- Equipped with Koa Router.
pnpx create-node-typescript-server # or npx create-node-typescript-server
Or
- Clone the repository
- Copy the environment variables
- Install the dependencies
- Change some stuff
# (1)
git clone https://github.com/kauefraga/node-typescript-server.git {your-project-name}
cd {your-project-name}
# (2)
cp .env.example .env
# (3)
pnpm install --frozen-lockfile # or npm ci
# (4)
# You should rewrite the README for your project
# You should change the "name" in the package.json
# You probably will need to remove the example files
Look at the tsconfig.json.
I highly recommend you to read those resources:
Look at the .env.example.
PORT
: the HTTP server port number (default: 3333).
Note
Currently, i am using Node 18.17.1, therefore i choose dotenv
package to load environment variables because it's the most stable solution. If you are reading it in the future (20.8.x LTS or above), consider removing dotenv
and using node --env-file=.env
.
Run tests:
pnpm test # or npm run test
Look at the vitest config. Powered by Vitest.
It's a monolithic application and you should keep it like that for this boilerplate.
Below you can see an explanation of the codebase:
src
- It's where our code lives.core
- Specifications and business rules will be here.http
- The HTTP thing (server, API, ...) will go here.infra
- Infrastructure stuff, such as database, migrations, cache...
core/domain
entities/models/schemas
- Definitions of our entities (User, Book, Post, Pet, etc...).repositories
- Interfaces and implementations of repositories.usecases
- Use cases of our application.
Where is the test folder?? You will see the tests right next of their definition/implementation.
Look at the source code.
The following list has some suggestions, remember that you don't need to follow them strictly, as the codebase specifications.
- I suggest you to write git commit messages following Gitmoji and/or Conventional Commits.
- Also, configure a linter to make your codebase more consistent. Here's a guide for eslint setup.
- Type
npx create-node-typescript-server
on your terminal and hit enter 🧞♂️
This project is licensed under the MIT License - See the LICENSE for more information.