Skip to content

Commit b45af47

Browse files
committed
feat: add examples directory
1 parent 9c75d92 commit b45af47

File tree

17 files changed

+3483
-42
lines changed

17 files changed

+3483
-42
lines changed

examples/full/eslint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import baseConfig from '../../eslint.config.mjs';
2+
3+
export default [...baseConfig];

examples/full/package.json

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"name": "@examples/full",
3+
"version": "0.0.1",
4+
"private": true,
5+
"nx": {
6+
"targets": {
7+
"build": {
8+
"executor": "nx:run-commands",
9+
"outputs": ["{projectRoot}/dist"],
10+
"options": {
11+
"command": "webpack-cli build",
12+
"args": [
13+
"--node-env=production"
14+
],
15+
"cwd": "examples/full"
16+
},
17+
"configurations": {
18+
"development": {
19+
"args": [
20+
"--node-env=development"
21+
]
22+
}
23+
}
24+
},
25+
"prune-lockfile": {
26+
"dependsOn": [
27+
"build"
28+
],
29+
"cache": true,
30+
"executor": "@nx/js:prune-lockfile",
31+
"outputs": [
32+
"{workspaceRoot}/examples/full/dist/package.json",
33+
"{workspaceRoot}/examples/full/dist/pnpm-lock.yaml"
34+
],
35+
"options": {
36+
"buildTarget": "build"
37+
}
38+
},
39+
"copy-workspace-modules": {
40+
"dependsOn": [
41+
"build"
42+
],
43+
"cache": true,
44+
"outputs": [
45+
"{workspaceRoot}/examples/full/dist/workspace_modules"
46+
],
47+
"executor": "@nx/js:copy-workspace-modules",
48+
"options": {
49+
"buildTarget": "build"
50+
}
51+
},
52+
"prune": {
53+
"dependsOn": [
54+
"prune-lockfile",
55+
"copy-workspace-modules"
56+
],
57+
"executor": "nx:noop"
58+
},
59+
"serve": {
60+
"continuous": true,
61+
"executor": "@nx/js:node",
62+
"defaultConfiguration": "development",
63+
"dependsOn": [
64+
"build"
65+
],
66+
"options": {
67+
"buildTarget": "@examples/full:build",
68+
"runBuildTargetDependencies": false
69+
},
70+
"configurations": {
71+
"development": {
72+
"buildTarget": "@examples/full:build:development"
73+
},
74+
"production": {
75+
"buildTarget": "@examples/full:build:production"
76+
}
77+
}
78+
}
79+
}
80+
},
81+
"dependencies": {}
82+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Controller, Get } from '@nestjs/common';
2+
import { AppService } from './app.service';
3+
4+
@Controller()
5+
export class AppController {
6+
constructor(private readonly appService: AppService) {}
7+
8+
@Get()
9+
getData() {
10+
return this.appService.getData();
11+
}
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Module } from '@nestjs/common';
2+
import { AppController } from './app.controller';
3+
import { AppService } from './app.service';
4+
5+
@Module({
6+
imports: [],
7+
controllers: [AppController],
8+
providers: [AppService],
9+
})
10+
export class AppModule {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Injectable } from '@nestjs/common';
2+
3+
@Injectable()
4+
export class AppService {
5+
getData(): { message: string } {
6+
return { message: 'Hello API' };
7+
}
8+
}

examples/full/src/assets/.gitkeep

Whitespace-only changes.

examples/full/src/main.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* This is not a production server yet!
3+
* This is only a minimal backend to get started.
4+
*/
5+
import { Logger } from '@nestjs/common';
6+
import { NestFactory } from '@nestjs/core';
7+
import { AppModule } from './app/app.module';
8+
9+
async function bootstrap() {
10+
const app = await NestFactory.create(AppModule);
11+
const globalPrefix = 'api';
12+
app.setGlobalPrefix(globalPrefix);
13+
const port = process.env.PORT || 3000;
14+
await app.listen(port);
15+
Logger.log(
16+
`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`,
17+
);
18+
}
19+
20+
bootstrap();

examples/full/tsconfig.app.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"outDir": "dist",
5+
"types": ["node"],
6+
"rootDir": "src",
7+
"tsBuildInfoFile": "dist/tsconfig.app.tsbuildinfo",
8+
"experimentalDecorators": true,
9+
"emitDecoratorMetadata": true,
10+
"target": "es2021"
11+
},
12+
"include": ["src/**/*.ts"],
13+
"exclude": ["eslint.config.js", "eslint.config.cjs", "eslint.config.mjs"]
14+
}

examples/full/tsconfig.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"files": [],
4+
"include": [],
5+
"references": [
6+
{
7+
"path": "./tsconfig.app.json"
8+
}
9+
]
10+
}

examples/full/webpack.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');
2+
const { join } = require('path');
3+
4+
module.exports = {
5+
output: {
6+
path: join(__dirname, 'dist'),
7+
...(process.env.NODE_ENV !== 'production' && {
8+
devtoolModuleFilenameTemplate: '[absolute-resource-path]',
9+
}),
10+
},
11+
plugins: [
12+
new NxAppWebpackPlugin({
13+
target: 'node',
14+
compiler: 'tsc',
15+
main: './src/main.ts',
16+
tsConfig: './tsconfig.app.json',
17+
assets: ['./src/assets'],
18+
optimization: false,
19+
outputHashing: 'none',
20+
generatePackageJson: true,
21+
sourceMaps: true,
22+
}),
23+
],
24+
};

0 commit comments

Comments
 (0)