18 |
19 |
20 |
21 | TypeScript ESM boilerplate sample
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
55 |
56 |
--------------------------------------------------------------------------------
/ts-boilerplate-common/src/public/styles.css:
--------------------------------------------------------------------------------
1 | * {
2 | box-sizing: border-box;
3 | }
4 |
5 | html, body {
6 | height: 100%;
7 | }
8 |
9 | #messages .toast-container {
10 | margin-bottom: 12px;
11 | }
12 |
13 | .background-user {
14 | background-color: #2372cc;
15 | }
16 |
17 | .background-assistant {
18 | background-color: #2c8310;
19 | }
--------------------------------------------------------------------------------
/ts-boilerplate-common/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es5",
5 | "moduleResolution": "node",
6 |
7 | "outDir": "dist",
8 | "rootDir": "./src",
9 |
10 | "strict": true,
11 | "noImplicitAny": true,
12 |
13 | "sourceMap": true,
14 | "resolveJsonModule": true,
15 | "esModuleInterop": true,
16 | "skipLibCheck": true
17 | }
18 | }
--------------------------------------------------------------------------------
/ts-boilerplate-esm/.gitignore:
--------------------------------------------------------------------------------
1 | dist
2 | *.env
3 | node_modules
4 | .azure
5 | .DS_Store
6 | Thumbs.db
7 | *.log*
--------------------------------------------------------------------------------
/ts-boilerplate-esm/.prettierignore:
--------------------------------------------------------------------------------
1 | # Ignore artifacts:
2 | dist
3 | coverage
4 |
5 | # Ignore all node_modules directories:
6 | node_modules
7 |
8 | # Ignore all .env files:
9 | .env
10 |
11 |
--------------------------------------------------------------------------------
/ts-boilerplate-esm/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true,
3 | "trailingComma": "all",
4 | "printWidth": 80,
5 | "tabWidth": 2,
6 | "semi": false
7 | }
--------------------------------------------------------------------------------
/ts-boilerplate-esm/http/get-root.http:
--------------------------------------------------------------------------------
1 | GET http://localhost:3000 HTTP/1.1
--------------------------------------------------------------------------------
/ts-boilerplate-esm/http/post-data.http:
--------------------------------------------------------------------------------
1 | POST http://localhost:3000/data HTTP/1.1
2 | content-type: application/json
3 |
4 | {
5 | "name": "sample",
6 | "time": "Wed, 21 Oct 2015 18:27:50 GMT"
7 | }
--------------------------------------------------------------------------------
/ts-boilerplate-esm/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ts-boilerplate-common",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "type": "module",
6 | "scripts": {
7 | "format": "npx prettier . --write",
8 | "start": "tsc && node dist/index.js"
9 | },
10 | "author": "",
11 | "license": "MIT",
12 | "description": "",
13 | "dependencies": {
14 | "@fastify/static": "^8.0.2",
15 | "fastify": "^5.1.0"
16 | },
17 | "devDependencies": {
18 | "@types/node": "^22.9.1",
19 | "prettier": "3.3.3",
20 | "typescript": "^5.6.3"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ts-boilerplate-esm/readme.md:
--------------------------------------------------------------------------------
1 | # TypeScript ESM boilerplate
2 |
3 | * Node.js v20 is required
--------------------------------------------------------------------------------
/ts-boilerplate-esm/src/index.ts:
--------------------------------------------------------------------------------
1 | import Fastify from 'fastify'
2 |
3 | const fastify = Fastify({
4 | logger: false
5 | })
6 |
7 | fastify.get('/', function (_, reply) {
8 | reply.send({ hello: 'world' })
9 | })
10 |
11 | fastify.listen({ port: 3000 }, function (err, address) {
12 | if (err) {
13 | fastify.log.error(err)
14 | process.exit(1)
15 | }
16 | // Server is now listening on ${address}
17 | })
--------------------------------------------------------------------------------
/ts-boilerplate-esm/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "NodeNext",
4 | "target": "ESNext",
5 | "moduleResolution": "NodeNext",
6 |
7 | "outDir": "dist",
8 | "rootDir": "./src",
9 |
10 | "strict": true,
11 | "noImplicitAny": true,
12 |
13 | "sourceMap": true,
14 | "resolveJsonModule": true,
15 | "esModuleInterop": true,
16 | "skipLibCheck": true
17 | },
18 | "include": ["src/**/*"],
19 | "exclude": ["node_modules", "dist"]
20 | }
--------------------------------------------------------------------------------