Module 1 Summary
This lesson is a summary of the work we've done in Module 1.0.
Get the project source code below, and follow along with the lesson material.
Download Project Source CodeTo set up the project on your local machine, please follow the directions provided in the README.md
file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.
Module 1 Summary
This lesson is a summary of what we've done in Module 1.0.
In Module 1.0, we've built a very simple Node/Express/Typescript project.
package.json
package.json
In the package.json
file of our app, we can see the dependencies
and devDependencies
our app depends on. body-parser
and the express
packages are our app's main dependencies. In our development dependencies, we've introduced the TypeScript ESLint packages, the eslint
package, nodemon
, and typescript
. We've introduced two scripts in our app; the start
script which allows us to start the server and the build
script which allows us to compile our TypeScript code to valid JavaScript.
{
"name": "tinyhouse-v1-server",
"version": "0.1.0",
"dependencies": {
"body-parser": "^1.19.0",
"express": "^4.17.1"
},
"devDependencies": {
"@types/body-parser": "^1.17.0",
"@types/express": "^4.17.0",
"@types/node": "^12.0.10",
"@typescript-eslint/eslint-plugin": "^1.11.0",
"@typescript-eslint/parser": "^1.11.0",
"eslint": "^6.0.1",
"nodemon": "^2.0.4",
"ts-node": "^8.3.0",
"typescript": "^3.5.2"
},
"scripts": {
"start": "nodemon src/index.ts",
"build": "tsc -p ./"
}
}
.eslintrc.json
.eslintrc.json
The .eslintrc.json
file sets up the configuration for our ESLint setup. We're using the @typescript-eslint/parser
package to help parse TypeScript code. We're extending the @typescript-eslint/recommended
package which contains a series of recommended rules. We've also added and customized a few rules of our own.
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"extends": ["plugin:@typescript-eslint/recommended"],
"env": { "node": true },
"rules": {
"indent": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/explicit-function-return-type": "off"
}
}
tsconfig.json
tsconfig.json
The tsconfig.json
file is responsible for setting up the configuration of our TypeScript project. We've stated the src/
folder to be the root directory of our TypeScript code. The output directory of compiled JavaScript code will be a build/
folder that is to be created in the root of the server project directory. We've introduced a strict: true
field in our configuration to enable a series of strict type-checking options.
This lesson preview is part of the The newline Guide to Building Your First GraphQL Server with Node and TypeScript course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.
Get unlimited access to The newline Guide to Building Your First GraphQL Server with Node and TypeScript, plus 70+ \newline books, guides and courses with the \newline Pro subscription.