create-express-typescript-application.
create-express-typescript-application creates a new lightweight express application which is fully customizable for your use case. With the support of TypeScript, it allows a robust NodeJS express app to serve as an RESTful backend server.
There are three modes of create-express-typescript-application, mainly:
- plain mode - lightweight express typescript app (--type plain)
- typeorm mode - lightweight express typescript app with typeorm (sqlite included) and swagger (OpenAPI documentation) integrated
- prisma mode - fullweight express typescript app with prisma (relational database ORM) and swagger (OpenAPI documentation) integrated
You are highly recommended to use typeorm template if database is required in this project, otherwise, plain mode.
When you run create-express-typescript-application, it sets up a very simple application without junk packages. The src/app/sample folder shows how easy it is to create new routes.
Pre-requisite: Node, npm and git are locally installed.
Install this package globally in your environment:
$ npm install -g create-express-typescript-application
Or use npx
to execute this package without installing it globally:
$ npx create-express-typescript-application
Options:
-V, --version output the version number
-d, --debug output extra debugging
-t, --template <template> specify only prisma, plain or typeorm
-p, --prisma define template prisma
-y, --typeorm define template typeorm
-h, --help display help for command
The --prisma
option integrates Prisma ORM into any of the lightweight app templates.
The quickest way to get started is use npx and pass in the name of the project you want to create.
Create a new Express app with the default plain
template:
$ create-express-typescript-application {project-name-without-spaces}
Or create a new Express app using a specific template:
# plain (lightweight, default)
$ create-express-typescript-application {project-name-without-spaces} -t plain
# typeorm (lightweight)
$ create-express-typescript-application {project-name-without-spaces} -t typeorm
# prisma (fullweight)
$ create-express-typescript-application {project-name-without-spaces} -t prisma
Navigate into the generated folder to work on your new app:
$ cd {project-name-without-spaces}
- Run the server in development mode:
npm run dev
.- with the default port, your app will be accessible at
http://localhost:8080/
. - if Swagger is included, your API docs will be accessible at
http://localhost:8080/docs
.
- with the default port, your app will be accessible at
- Build the project for production:
npm run build
. - Run the production build:
npm start
.- note: this requires the app to be built first.