To clone and run this application, you'll need Git and Node.js (which comes with npm) installed on your computer. From your command line:
# Clone this repository
$ git clone https://github.com/tradelab/saas-messaging.git
# Go into the repository
$ cd saas-messaging
# Install dependencies
$ npm install
# Run the app using nodemon and ts-node for hot reloading
$ npm run start
It will launch a live compile and hotreload the application as you edit it.
Note: If you're using Linux Bash for Windows, see this guide or use node
from the command prompt.
-
run the application :
npm run start
-
build the application :
npm run build
-
run the linter :
npm run ts:lint
-
run the test :
npm run test
The most obvious difference in a TypeScript + Node project is the folder structure.
In a TypeScript project, it's best to have separate source and distributable files.
TypeScript (.ts
) files live in your src
folder and after compilation are output as JavaScript (.js
) in the lib
folder.
The test
folder remain top level as expected.
The full folder structure of this app is explained below:
Note! Make sure you have already built the app using
npm run build
Name | Description |
---|---|
lib | Contains the distributable (or output) from your TypeScript build. This is the code you ship |
node_modules | Contains all your npm dependencies |
src | Contains your source code that will be compiled to the lib dir |
src/index.ts | Entry point to your express app |
test | Contains your tests. Seperate from source because there is a different build process. |
jest.config.js | Used to configure Jest |
package.json | File that contains npm dependencies as well as build scripts |
tsconfig.json | Config settings for compiling server code written in TypeScript |
tslint.json | Config settings for TSLint code style checking |
For this project, I chose Jest as our test framework. While Mocha is probably more common, Mocha seems to be looking for a new maintainer and setting up TypeScript testing in Jest is wicked simple.
Jest's configuration lives in jest.config.js