This is a skeleton app for people who want to use TypeScript in ExpressJS. A docker-compose file is included for those who want to run it in a container.
You don't have to use the docker-compose file if you're fine with installing NodeJS and NPM locally. Feel free to delete it if that's the case.
Make sure you have NodeJS installed (preferably the LTS version). This will also install npm
. For Windows users you might consider Chocolaty and for Mac users obviously Brew. These are both package managers that will help you install and update all kinds of packages via the CLI. Highly recommended.
- Open a terminal window (command prompt, git bash, powershell)
- Check if NodeJS is installed by typing
node --version
into the terminal. It should print a line with something likev18.18.0
. - Check if NPM is installed by typing
npm --version
into the terminal. It should print a line with something like9.8.0
.
- Clone or download this repository to your computer
- Open a terminal in the project directory.
- Install the dependencies by running
npm install
. - Run
npm run dev
to start developing - Run
npm run start
to start the server
- To use the provided
.editorconfig
file, install the EditorConfig plugin. - To use the provided
.eslintrc.cjs
file, install the ESLint plugin.
If you're like me and you dislike NodeJS and NPM piling up heaps of folders on your pc, run TypeScript in Docker!
- Install Docker Desktop.
- Open a terminal window (Powershell on Windows, regular command prompt will not work).
- Clone this repository.
- Move to this folder inside the terminal.
- Run
docker-compose up
and open a new terminal OR rundocker-compose up -d
which allows you to work in the same terminal. - Follow the steps from Instructions from step 4, but prefix all the commands with
docker-compose exec ts-app
. - Close the docker container by pressing
ctrl
+c
ordocker-compose down
, respectively for step 5
We use ES6 module system to import and export modules.
We save credentials to other services in a variables.env
file. This file is included in this template. However, it is common use not to include it in a public repository. There are some default key value pairs included to demonstrate its working.
You can change the ports of your server via variables.env
With our npmr run
commands we do not transpile our ts files to the filesystem. This is on purpose, we choose to transpile in memory. Hot-module replacement is also in place. If your run npm run dev
and you update your code, the server will automatically restart.
In this project Prisma is used for Object Relation Mapping. It comes with all kind of utilities as models, seeds and migrations.