├── .env.example
├── .env.test.example
├── .eslintignore
├── .eslintrc.json
├── .gitignore
├── Insomnia.json
├── README.md
├── db
└── migrations
│ ├── 20230130201442_create-transactions.ts
│ └── 20230131174143_add-session-id-to-transactions.ts
├── knexfile.ts
├── package-lock.json
├── package.json
├── src
├── @types
│ └── knex.d.ts
├── app.ts
├── database.ts
├── env
│ └── index.ts
├── middlewares
│ └── check-session-id-exists.ts
├── routes
│ └── transactions.ts
└── server.ts
├── test
└── transactions.spec.ts
└── tsconfig.json
/.env.example:
--------------------------------------------------------------------------------
1 | NODE_ENV=development
2 | DATABASE_CLIENT=sqlite
3 | DATABASE_URL="./db/app.db"
4 |
--------------------------------------------------------------------------------
/.env.test.example:
--------------------------------------------------------------------------------
1 | DATABASE_CLIENT=sqlite
2 | DATABASE_URL="./db/test.db"
3 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | build
3 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "@rocketseat/eslint-config/node"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Dependencies
2 | node_modules
3 |
4 | # Database
5 | db/*.db
6 |
7 | # Environment
8 | .env
9 | .env.test
10 |
11 | # Build
12 | build
13 |
--------------------------------------------------------------------------------
/Insomnia.json:
--------------------------------------------------------------------------------
1 | {"_type":"export","__export_format":4,"__export_date":"2023-02-01T20:22:40.507Z","__export_source":"insomnia.desktop.app:v2022.7.5","resources":[{"_id":"req_ed91814574bc4e86878916f620678c60","parentId":"fld_fde57ff960e741cfa9c08992ada42ce6","modified":1675282900103,"created":1675274837480,"url":"{{url}}/transactions","name":"Create Transaction","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"title\": \"Freelancer\",\n\t\"amount\": 4000,\n\t\"type\": \"credit\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"}],"authentication":{},"metaSortKey":-1675274837480,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_fde57ff960e741cfa9c08992ada42ce6","parentId":"wrk_6683084c854a4cb7b82a4e8dbd7850a0","modified":1675274834681,"created":1675274834681,"name":"Transactions","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1675274834681,"_type":"request_group"},{"_id":"wrk_6683084c854a4cb7b82a4e8dbd7850a0","parentId":null,"modified":1675274822458,"created":1675274822458,"name":"Ignite Node.js API REST","description":"","scope":"collection","_type":"workspace"},{"_id":"req_803bc03551fc4972a2722a2cb05e014d","parentId":"fld_fde57ff960e741cfa9c08992ada42ce6","modified":1675282903406,"created":1675275391281,"url":"{{url}}/transactions","name":"List Transactions","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1674723831961,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_8bedf7a794e04d86906b9d3596fa60fb","parentId":"fld_fde57ff960e741cfa9c08992ada42ce6","modified":1675282896047,"created":1675275563331,"url":"{{url}}/transactions/584460a4-43e5-4160-b0b6-64e4b8f24a2b","name":"Get Transaction","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1674448329201.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_8d6552f7f105486fadad1cced33f528a","parentId":"fld_fde57ff960e741cfa9c08992ada42ce6","modified":1675282909513,"created":1675275798228,"url":"{{url}}/transactions/summary","name":"Get summary","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1674310577821.75,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_31bdc5b004066952d6c9208362a0d4abeb456c66","parentId":"wrk_6683084c854a4cb7b82a4e8dbd7850a0","modified":1675274822475,"created":1675274822475,"name":"Base Environment","data":{},"dataPropertyOrder":null,"color":null,"isPrivate":false,"metaSortKey":1675274822475,"_type":"environment"},{"_id":"jar_31bdc5b004066952d6c9208362a0d4abeb456c66","parentId":"wrk_6683084c854a4cb7b82a4e8dbd7850a0","modified":1675279069534,"created":1675274822478,"name":"Default Jar","cookies":[{"key":"sessionId","value":"81dcaa6e-cacf-443d-85aa-f890eaf58c2c","maxAge":604800000,"domain":"localhost","path":"/","hostOnly":true,"creation":"2023-02-01T19:17:49.534Z","lastAccessed":"2023-02-01T19:17:49.534Z","id":"8720411540337754"}],"_type":"cookie_jar"},{"_id":"spc_3054d345533948f1bfeff7c033dc1d8e","parentId":"wrk_6683084c854a4cb7b82a4e8dbd7850a0","modified":1675274822459,"created":1675274822459,"fileName":"Ignite Node.js API REST","contents":"","contentType":"yaml","_type":"api_spec"},{"_id":"env_a82f480484c64db39043116e6428a2fb","parentId":"env_31bdc5b004066952d6c9208362a0d4abeb456c66","modified":1675282881837,"created":1675282847988,"name":"Dev","data":{"url":"http://localhost:3333"},"dataPropertyOrder":{"&":["url"]},"color":"#00ff11","isPrivate":false,"metaSortKey":1675282847988,"_type":"environment"},{"_id":"env_872535fc44ba4361b449b2dfbe1b3e93","parentId":"env_31bdc5b004066952d6c9208362a0d4abeb456c66","modified":1675282886919,"created":1675282853385,"name":"Prod","data":{"url":""},"dataPropertyOrder":{"&":["url"]},"color":"#bb00ff","isPrivate":false,"metaSortKey":1675282853385,"_type":"environment"}]}
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RF
2 |
3 | - [x] O usuário deve poder criar uma nova transação;
4 | - [x] O usuário deve poder obter um resumo da sua conta;
5 | - [x] O usuário deve poder listar todas transações que já ocorreram;
6 | - [x] O usuário deve poder visualizar uma transação única;
7 |
8 | # RN
9 |
10 | - [x] A transação pode ser do tipo crédito que somará ao valor total, ou débito subtrairá;
11 | - [ ] Deve ser possível identificarmos o usuário entre as requisições;
12 | - [ ] O usuário só pode visualizar transações o qual ele criou;
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/db/migrations/20230130201442_create-transactions.ts:
--------------------------------------------------------------------------------
1 | import { Knex } from 'knex'
2 |
3 | export async function up(knex: Knex): Promise {
4 | await knex.schema.createTable('transactions', (table) => {
5 | table.uuid('id').primary()
6 | table.text('title').notNullable()
7 | table.decimal('amount', 10, 2).notNullable()
8 | table.timestamp('created_at').defaultTo(knex.fn.now()).notNullable()
9 | })
10 | }
11 |
12 | export async function down(knex: Knex): Promise {
13 | await knex.schema.dropTable('transactions')
14 | }
15 |
--------------------------------------------------------------------------------
/db/migrations/20230131174143_add-session-id-to-transactions.ts:
--------------------------------------------------------------------------------
1 | import { Knex } from 'knex'
2 |
3 | export async function up(knex: Knex): Promise {
4 | await knex.schema.alterTable('transactions', (table) => {
5 | table.uuid('session_id').after('id').index()
6 | })
7 | }
8 |
9 | export async function down(knex: Knex): Promise {
10 | await knex.schema.alterTable('transactions', (table) => {
11 | table.dropColumn('session_id')
12 | })
13 | }
14 |
--------------------------------------------------------------------------------
/knexfile.ts:
--------------------------------------------------------------------------------
1 | import { config } from './src/database'
2 |
3 | export default config
4 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "02-api-rest-nodejs",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "engines": {
7 | "node": ">=18"
8 | },
9 | "scripts": {
10 | "dev": "tsx watch src/server.ts",
11 | "knex": "node --no-warnings --loader tsx ./node_modules/.bin/knex",
12 | "lint": "eslint src --ext .ts --fix",
13 | "build": "tsup src --out-dir build",
14 | "test": "vitest"
15 | },
16 | "keywords": [],
17 | "author": "",
18 | "license": "ISC",
19 | "dependencies": {
20 | "@fastify/cookie": "^8.3.0",
21 | "dotenv": "^16.0.3",
22 | "fastify": "^4.12.0",
23 | "knex": "^2.4.2",
24 | "pg": "^8.9.0",
25 | "zod": "^3.20.2"
26 | },
27 | "devDependencies": {
28 | "@rocketseat/eslint-config": "^1.2.0",
29 | "@types/node": "^18.11.18",
30 | "@types/supertest": "^2.0.12",
31 | "eslint": "^8.33.0",
32 | "sqlite3": "^5.1.4",
33 | "supertest": "^6.3.3",
34 | "tsup": "^6.5.0",
35 | "tsx": "^3.12.2",
36 | "typescript": "^4.9.5",
37 | "vitest": "^0.28.3"
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/@types/knex.d.ts:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line
2 | import { Knex } from 'knex'
3 | // ou faça apenas:
4 | // import 'knex'
5 |
6 | declare module 'knex/types/tables' {
7 | export interface Tables {
8 | transactions: {
9 | id: string
10 | title: string
11 | amount: number
12 | created_at: string
13 | session_id?: string
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/app.ts:
--------------------------------------------------------------------------------
1 | import fastify from 'fastify'
2 | import cookie from '@fastify/cookie'
3 |
4 | import { transactionsRoutes } from './routes/transactions'
5 |
6 | export const app = fastify()
7 |
8 | app.register(cookie)
9 |
10 | app.register(transactionsRoutes, {
11 | prefix: 'transactions',
12 | })
13 |
--------------------------------------------------------------------------------
/src/database.ts:
--------------------------------------------------------------------------------
1 | import { Knex, knex as setupKnex } from 'knex'
2 | import { env } from './env'
3 |
4 | export const config: Knex.Config = {
5 | client: env.DATABASE_CLIENT,
6 | connection:
7 | env.DATABASE_CLIENT === 'sqlite'
8 | ? {
9 | filename: env.DATABASE_URL,
10 | }
11 | : env.DATABASE_URL,
12 | useNullAsDefault: true,
13 | migrations: {
14 | extension: 'ts',
15 | directory: './db/migrations',
16 | },
17 | }
18 |
19 | export const knex = setupKnex(config)
20 |
--------------------------------------------------------------------------------
/src/env/index.ts:
--------------------------------------------------------------------------------
1 | import { config } from 'dotenv'
2 | import { z } from 'zod'
3 |
4 | if (process.env.NODE_ENV === 'test') {
5 | config({ path: '.env.test' })
6 | } else {
7 | config()
8 | }
9 |
10 | const envSchema = z.object({
11 | NODE_ENV: z.enum(['development', 'test', 'production']).default('production'),
12 | DATABASE_CLIENT: z.enum(['sqlite', 'pg']).default('sqlite'),
13 | DATABASE_URL: z.string(),
14 | PORT: z.coerce.number().default(3333),
15 | })
16 |
17 | const _env = envSchema.safeParse(process.env)
18 |
19 | if (_env.success === false) {
20 | console.error('⚠️ Invalid environment variables', _env.error.format())
21 |
22 | throw new Error('Invalid environment variables.')
23 | }
24 |
25 | export const env = _env.data
26 |
--------------------------------------------------------------------------------
/src/middlewares/check-session-id-exists.ts:
--------------------------------------------------------------------------------
1 | import { FastifyReply, FastifyRequest } from 'fastify'
2 |
3 | export async function checkSessionIdExists(
4 | request: FastifyRequest,
5 | reply: FastifyReply,
6 | ) {
7 | const sessionId = request.cookies.sessionId
8 |
9 | if (!sessionId) {
10 | return reply.status(401).send({
11 | error: 'Unauthorized.',
12 | })
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/routes/transactions.ts:
--------------------------------------------------------------------------------
1 | import { FastifyInstance } from 'fastify'
2 | import { z } from 'zod'
3 | import { randomUUID } from 'node:crypto'
4 | import { knex } from '../database'
5 | import { checkSessionIdExists } from '../middlewares/check-session-id-exists'
6 |
7 | export async function transactionsRoutes(app: FastifyInstance) {
8 | app.get(
9 | '/',
10 | {
11 | preHandler: [checkSessionIdExists],
12 | },
13 | async (request) => {
14 | const { sessionId } = request.cookies
15 |
16 | const transactions = await knex('transactions')
17 | .where('session_id', sessionId)
18 | .select()
19 |
20 | return { transactions }
21 | },
22 | )
23 |
24 | app.get(
25 | '/:id',
26 | {
27 | preHandler: [checkSessionIdExists],
28 | },
29 | async (request) => {
30 | const getTransactionsParamsSchema = z.object({
31 | id: z.string().uuid(),
32 | })
33 |
34 | const { id } = getTransactionsParamsSchema.parse(request.params)
35 |
36 | const { sessionId } = request.cookies
37 |
38 | const transaction = await knex('transactions')
39 | .where({
40 | session_id: sessionId,
41 | id,
42 | })
43 | .first()
44 |
45 | return {
46 | transaction,
47 | }
48 | },
49 | )
50 |
51 | app.get(
52 | '/summary',
53 | {
54 | preHandler: [checkSessionIdExists],
55 | },
56 | async (request) => {
57 | const { sessionId } = request.cookies
58 |
59 | const summary = await knex('transactions')
60 | .where('session_id', sessionId)
61 | .sum('amount', { as: 'amount' })
62 | .first()
63 |
64 | return { summary }
65 | },
66 | )
67 |
68 | app.post('/', async (request, reply) => {
69 | const createTransactionBodySchema = z.object({
70 | title: z.string(),
71 | amount: z.number(),
72 | type: z.enum(['credit', 'debit']),
73 | })
74 |
75 | const { title, amount, type } = createTransactionBodySchema.parse(
76 | request.body,
77 | )
78 |
79 | let sessionId = request.cookies.sessionId
80 |
81 | if (!sessionId) {
82 | sessionId = randomUUID()
83 |
84 | reply.setCookie('sessionId', sessionId, {
85 | path: '/',
86 | maxAge: 1000 * 60 * 60 * 24 * 7, // 7 days
87 | })
88 | }
89 |
90 | await knex('transactions').insert({
91 | id: randomUUID(),
92 | title,
93 | amount: type === 'credit' ? amount : amount * -1,
94 | session_id: sessionId,
95 | })
96 |
97 | return reply.status(201).send()
98 | })
99 | }
100 |
--------------------------------------------------------------------------------
/src/server.ts:
--------------------------------------------------------------------------------
1 | import { app } from './app'
2 | import { env } from './env'
3 |
4 | app
5 | .listen({
6 | port: env.PORT,
7 | })
8 | .then(() => {
9 | console.log('HTTP Server Running!')
10 | })
11 |
--------------------------------------------------------------------------------
/test/transactions.spec.ts:
--------------------------------------------------------------------------------
1 | import { afterAll, beforeAll, beforeEach, describe, expect, it } from 'vitest'
2 | import { execSync } from 'node:child_process'
3 | import request from 'supertest'
4 | import { app } from '../src/app'
5 |
6 | describe('Transactions routes', () => {
7 | beforeAll(async () => {
8 | await app.ready()
9 | })
10 |
11 | afterAll(async () => {
12 | await app.close()
13 | })
14 |
15 | beforeEach(() => {
16 | execSync('npm run knex migrate:rollback --all')
17 | execSync('npm run knex migrate:latest')
18 | })
19 |
20 | it('should be able to create a new transaction', async () => {
21 | await request(app.server)
22 | .post('/transactions')
23 | .send({
24 | title: 'New transaction',
25 | amount: 5000,
26 | type: 'credit',
27 | })
28 | .expect(201)
29 | })
30 |
31 | it('should be able to list all transactions', async () => {
32 | const createTransactionResponse = await request(app.server)
33 | .post('/transactions')
34 | .send({
35 | title: 'New transaction',
36 | amount: 5000,
37 | type: 'credit',
38 | })
39 |
40 | const cookies = createTransactionResponse.get('Set-Cookie')
41 |
42 | const listTransactionsResponse = await request(app.server)
43 | .get('/transactions')
44 | .set('Cookie', cookies)
45 | .expect(200)
46 |
47 | expect(listTransactionsResponse.body.transactions).toEqual([
48 | expect.objectContaining({
49 | title: 'New transaction',
50 | amount: 5000,
51 | }),
52 | ])
53 | })
54 |
55 | it('should be able to get a specific transaction', async () => {
56 | const createTransactionResponse = await request(app.server)
57 | .post('/transactions')
58 | .send({
59 | title: 'New transaction',
60 | amount: 5000,
61 | type: 'credit',
62 | })
63 |
64 | const cookies = createTransactionResponse.get('Set-Cookie')
65 |
66 | const listTransactionsResponse = await request(app.server)
67 | .get('/transactions')
68 | .set('Cookie', cookies)
69 | .expect(200)
70 |
71 | const transactionId = listTransactionsResponse.body.transactions[0].id
72 |
73 | const getTransactionResponse = await request(app.server)
74 | .get(`/transactions/${transactionId}`)
75 | .set('Cookie', cookies)
76 | .expect(200)
77 |
78 | expect(getTransactionResponse.body.transaction).toEqual(
79 | expect.objectContaining({
80 | title: 'New transaction',
81 | amount: 5000,
82 | }),
83 | )
84 | })
85 |
86 | it('should be able to get the summary', async () => {
87 | const createTransactionResponse = await request(app.server)
88 | .post('/transactions')
89 | .send({
90 | title: 'Credit transaction',
91 | amount: 5000,
92 | type: 'credit',
93 | })
94 |
95 | const cookies = createTransactionResponse.get('Set-Cookie')
96 |
97 | await request(app.server)
98 | .post('/transactions')
99 | .set('Cookie', cookies)
100 | .send({
101 | title: 'Debit transaction',
102 | amount: 2000,
103 | type: 'debit',
104 | })
105 |
106 | const summaryResponse = await request(app.server)
107 | .get('/transactions/summary')
108 | .set('Cookie', cookies)
109 | .expect(200)
110 |
111 | expect(summaryResponse.body.summary).toEqual({
112 | amount: 3000,
113 | })
114 | })
115 | })
116 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | /* Visit https://aka.ms/tsconfig to read more about this file */
4 |
5 | /* Projects */
6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12 |
13 | /* Language and Environment */
14 | "target": "es2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16 | // "jsx": "preserve", /* Specify what JSX code is generated. */
17 | // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26 |
27 | /* Modules */
28 | "module": "commonjs", /* Specify what module code is generated. */
29 | // "rootDir": "./", /* Specify the root folder within your source files. */
30 | // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38 | // "resolveJsonModule": true, /* Enable importing .json files. */
39 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */
40 |
41 | /* JavaScript Support */
42 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
43 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
44 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
45 |
46 | /* Emit */
47 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
48 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */
49 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
51 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
52 | // "outDir": "./", /* Specify an output folder for all emitted files. */
53 | // "removeComments": true, /* Disable emitting comments. */
54 | // "noEmit": true, /* Disable emitting files from a compilation. */
55 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
56 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
57 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
58 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
59 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
61 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
62 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
63 | // "newLine": "crlf", /* Set the newline character for emitting files. */
64 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
65 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
66 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
67 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
68 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
69 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
70 |
71 | /* Interop Constraints */
72 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
73 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
74 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
75 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
76 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
77 |
78 | /* Type Checking */
79 | "strict": true, /* Enable all strict type-checking options. */
80 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
81 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
82 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
83 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
84 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
85 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
86 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
87 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
88 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
89 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
90 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
94 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
96 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
97 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
98 |
99 | /* Completeness */
100 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
101 | "skipLibCheck": true /* Skip type checking all .d.ts files. */
102 | }
103 | }
104 |
--------------------------------------------------------------------------------