Skip to content

Commit

Permalink
chore: ignore some dev log
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Aug 25, 2024
1 parent 7e89a9b commit 75c514d
Show file tree
Hide file tree
Showing 15 changed files with 4,846 additions and 54 deletions.
4 changes: 2 additions & 2 deletions apps/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ layout: home

hero:
name: "Electron Vite Monorepo"
text: "Electron Turborepo monorepo with Vue, Vite boilerplate"
tagline: My great project tagline
text: ""
tagline: Electron Turborepo monorepo with Vue, Vite boilerplate
image:
src: /vite.png
alt: VitePress
Expand Down
5 changes: 5 additions & 0 deletions apps/server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Fastify MVC sample

Note that if you are running the Nest app on a remote machine, you may need to change the listen address, as per [these instructions](https://docs.nestjs.com/techniques/performance#adapter):

`await app.listen(3000, '0.0.0.0')`
9 changes: 9 additions & 0 deletions apps/server/nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"compilerOptions": {
"builder": "swc",
"typeCheck": true
},
"sourceRoot": "src"
}
6 changes: 6 additions & 0 deletions apps/server/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"watch": ["src"],
"ext": "ts",
"ignore": ["src/**/*.spec.ts"],
"exec": "ts-node ./src/main"
}
54 changes: 54 additions & 0 deletions apps/server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "@repo/server",
"version": "1.0.0",
"description": "Roxy Browser 开放 API",
"scripts": {
"prebuild": "rimraf dist",
"dev": "pnpm start:dev",
"build": "nest build --builder webpack",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint '{src,apps,libs,test}/**/*.ts' --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "echo 'No e2e tests implemented yet.'"
},
"dependencies": {
"@fastify/static": "7.0.4",
"@fastify/view": "9.1.0",
"@nestjs/common": "10.4.1",
"@nestjs/core": "10.4.1",
"@nestjs/platform-fastify": "10.4.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"handlebars": "4.7.8",
"reflect-metadata": "0.2.2",
"rimraf": "6.0.1",
"rxjs": "7.8.1"
},
"devDependencies": {
"@nestjs/cli": "10.4.4",
"@nestjs/schematics": "10.1.4",
"@nestjs/testing": "10.4.1",
"@swc/cli": "^0.4.0",
"@types/express": "4.17.21",
"@types/node": "22.4.1",
"@types/supertest": "6.0.2",
"jest": "29.7.0",
"supertest": "6.3.3",
"swc-loader": "^0.2.6",
"ts-jest": "29.1.2",
"ts-loader": "9.5.1",
"ts-node": "10.9.2",
"tsconfig-paths": "4.2.0",
"tsconfig-paths-webpack-plugin": "^4.1.0",
"typescript": "5.5.4",
"webpack": "^5.94.0",
"webpack-cli": "^5.1.4"
}
}
Empty file added apps/server/public/.gitkeep
Empty file.
10 changes: 10 additions & 0 deletions apps/server/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Controller, Get, Render } from '@nestjs/common'

@Controller()
export class AppController {
@Get()
@Render('index.hbs')
root() {
return { message: 'Hello world!' }
}
}
9 changes: 9 additions & 0 deletions apps/server/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common'
import { AppController } from './app.controller'

@Module({
imports: [],
controllers: [AppController],
providers: [],
})
export class AppModule {}
27 changes: 27 additions & 0 deletions apps/server/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { join } from 'node:path'
import { NestFactory } from '@nestjs/core'
import handlebars from 'handlebars'
import type { NestFastifyApplication } from '@nestjs/platform-fastify'
import { FastifyAdapter } from '@nestjs/platform-fastify'
import { AppModule } from './app.module'

async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
new FastifyAdapter(),
)
app.useStaticAssets({
root: join(__dirname, '..', 'public'),
prefix: '/public/',
})
app.setViewEngine({
engine: {
handlebars,
},
templates: join(__dirname, '..', 'views'),
})

await app.listen(3000)
console.log(`Application is running on: ${await app.getUrl()}`)
}
bootstrap()
4 changes: 4 additions & 0 deletions apps/server/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
}
19 changes: 19 additions & 0 deletions apps/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"incremental": true,
"target": "ES2021",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"baseUrl": "./",
"module": "commonjs",
"declaration": true,
"outDir": "./dist",
"removeComments": true,
"sourceMap": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
},
"include": [
"src/**/*"
]
}
13 changes: 13 additions & 0 deletions apps/server/views/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>App</title>
</head>

<body>
{{ message }}
</body>

</html>
73 changes: 73 additions & 0 deletions apps/server/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const path = require('node:path')
const { IgnorePlugin } = require('webpack')
const {
swcDefaultsFactory,
} = require('@nestjs/cli/lib/compiler/defaults/swc-defaults')
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')

/** @type { import('webpack').Configuration } */
module.exports = {
entry: './src/main',
externals: {},
module: {
rules: [
{
exclude: /node_modules/,
test: /\.ts$/,
use: {
loader: 'swc-loader',
options: swcDefaultsFactory().swcOptions,
},
},
],
},
node: {
__dirname: false,
__filename: false,
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist/'),
},
plugins: [
new IgnorePlugin({
checkResource(resource) {
const lazyImports = [
'@fastify/static',
'@fastify/view',
'@nestjs/microservices',
'@nestjs/microservices/microservices-module',
'@nestjs/platform-express',
'@nestjs/websockets/socket-module',
'amqp-connection-manager',
'amqplib',
'cache-manager',
'cache-manager/package.json',
'class-transformer/storage',
'hbs',
'ioredis',
'kafkajs',
'mqtt',
'nats',
]
if (!lazyImports.includes(resource)) {
return false
}
try {
require.resolve(resource, { paths: [process.cwd()] })
}
catch (err) {
// console.log(err)
return Boolean(err)
}
return false
},
}),
],
resolve: {
extensions: ['.js', '.json', '.ts'],
mainFields: ['main'],
plugins: [new TsconfigPathsPlugin({ configFile: 'tsconfig.json' })],
},
target: 'node',
}
Loading

0 comments on commit 75c514d

Please sign in to comment.