Skip to content

🧰 An awesome kickstart server with all the features you would expect, for Node + Typescript + Koa development.

License

Notifications You must be signed in to change notification settings

kauefraga/node-typescript-server

Repository files navigation

Node Typescript Server

GitHub top language NPM downloads GitHub's license GitHub last commit (branch)

🧰 An awesome kickstart server with all the features you would expect, for Node + Typescript + Koa development.

Features

  • Simplicity and flexibility.
  • Typescript out-of-box.
    • Use tsx to develop with a blazingly fast hot-reloading.
    • Use tsup to bundle code with no configuration.
  • Path aliases to clean up noisy paths, see more explanation.
  • Tiny and robust web framework, Koa.

⬇ How to install it

pnpx create-node-typescript-server # or npx create-node-typescript-server

Or

  1. Clone the repository
  2. Copy the environment variables
  3. Install the dependencies
  4. 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

🗺 Getting started

Typescript Settings

Look at the tsconfig.json.

I highly recommend you to read those resources:

Environment Variables

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.

Unit Tests

Run tests:

pnpm test # or npm run test

Look at the vitest config. Powered by Vitest.

🏗 Architecture and codebase

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.

⭐ Recommendations

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 🧞‍♂️

📝 License

This project is licensed under the MIT License - See the LICENSE for more information.

About

🧰 An awesome kickstart server with all the features you would expect, for Node + Typescript + Koa development.

Topics

Resources

License

Stars

Watchers

Forks