@vnodes/plugin 0.0.23 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/project/api/.env.template +4 -0
  2. package/dist/project/api/.swcrc.template +28 -0
  3. package/dist/project/api/README.md.template +35 -0
  4. package/dist/project/api/assets/favicon.png +0 -0
  5. package/dist/project/api/bin/__fileName__.mjs.template +3 -0
  6. package/dist/project/api/package.json.template +76 -0
  7. package/dist/project/api/scripts/build.mjs.template +1 -0
  8. package/dist/project/api/src/app.controller.spec.ts.template +39 -0
  9. package/dist/project/api/src/app.controller.ts.template +12 -0
  10. package/dist/project/api/src/app.module.ts.template +11 -0
  11. package/dist/project/api/src/app.service.ts.template +10 -0
  12. package/dist/project/api/src/index.ts.template +4 -0
  13. package/dist/project/api/src/main.ts.template +6 -0
  14. package/dist/project/api/src/src/main.ts.template +3 -0
  15. package/dist/project/api/tsconfig.json.template +13 -0
  16. package/dist/project/api/tsconfig.lib.json.template +14 -0
  17. package/dist/project/api/tsconfig.spec.json.template +14 -0
  18. package/dist/project/api/vitest.config.mts.template +18 -0
  19. package/dist/project/gql/.env.template +4 -0
  20. package/dist/project/gql/.swcrc.template +28 -0
  21. package/dist/project/gql/README.md.template +35 -0
  22. package/dist/project/gql/assets/favicon.png +0 -0
  23. package/dist/project/gql/bin/__fileName__.mjs.template +3 -0
  24. package/dist/project/gql/package.json.template +80 -0
  25. package/dist/project/gql/scripts/build.mjs.template +1 -0
  26. package/dist/project/gql/src/app.controller.spec.ts.template +39 -0
  27. package/dist/project/gql/src/app.controller.ts.template +12 -0
  28. package/dist/project/gql/src/app.module.ts.template +12 -0
  29. package/dist/project/gql/src/app.service.ts.template +10 -0
  30. package/dist/project/gql/src/index.ts.template +4 -0
  31. package/dist/project/gql/src/main.ts.template +6 -0
  32. package/dist/project/gql/src/resources/resource.module.ts.template +7 -0
  33. package/dist/project/gql/src/resources/sample/models/sample-create.input.ts.template +16 -0
  34. package/dist/project/gql/src/resources/sample/models/sample-model.ts.template +23 -0
  35. package/dist/project/gql/src/resources/sample/models/sample-query.args.ts.template +10 -0
  36. package/dist/project/gql/src/resources/sample/sample.module.ts.template +7 -0
  37. package/dist/project/gql/src/resources/sample/sample.resolver.ts.template +45 -0
  38. package/dist/project/gql/src/src/main.ts.template +3 -0
  39. package/dist/project/gql/tsconfig.json.template +13 -0
  40. package/dist/project/gql/tsconfig.lib.json.template +14 -0
  41. package/dist/project/gql/tsconfig.spec.json.template +14 -0
  42. package/dist/project/gql/vitest.config.mts.template +18 -0
  43. package/package.json +1 -1
@@ -0,0 +1,4 @@
1
+ APP_ID=<%- fileName %>
2
+ APP_DESC=<%- fileName %>
3
+ DB_URL=postgres://admin:password@localhost:5432/<%- orgname %>?schema=<%- fileName %>
4
+ DB_SCHEMA=<%- fileName %>
@@ -0,0 +1,28 @@
1
+ {
2
+ "jsc": {
3
+ "target": "es2021",
4
+ "parser": {
5
+ "syntax": "typescript",
6
+ "decorators": true,
7
+ "dynamicImport": true
8
+ },
9
+ "transform": {
10
+ "decoratorMetadata": true,
11
+ "legacyDecorator": true,
12
+ "useDefineForClassFields": true
13
+ },
14
+ "keepClassNames": true,
15
+ "externalHelpers": true,
16
+ "loose": false
17
+ },
18
+ "module": {
19
+ "type": "commonjs",
20
+ "noInterop": false
21
+ },
22
+ "sourceMaps": true,
23
+ "exclude": [
24
+ "vitest.config.mts",
25
+ ".*\\.spec.ts$",
26
+ ".*.js$"
27
+ ]
28
+ }
@@ -0,0 +1,35 @@
1
+ ![Npm version](https://img.shields.io/npm/v/<%- projectName %>)
2
+ ![Npm downloads](https://img.shields.io/npm/dm/<%- projectName %>)
3
+ ![Build Status](https://img.shields.io/github/actions/workflow/status/<%- orgname %>/<%- reponame %>/ci.yml)
4
+ ![Doc Status](https://img.shields.io/github/actions/workflow/status/<%- orgname %>/<%- reponame %>/doc.yml)
5
+ ![Bundle size](https://img.shields.io/bundlephobia/min/<%- projectName %>)
6
+
7
+ <p align="center">
8
+ <img srcset="./assets/favicon.png, <%- homepage %>/<%- directory %>/assets/favicon.png" alt="Logo" width="200" height="200" style="border-radius: 100%"/>
9
+ </p>
10
+
11
+ ## <%- projectName %>
12
+
13
+ Rest Api | <%- projectName %>
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pnpm add <%- projectName %>
19
+ ```
20
+
21
+ ## 💖 Support My Work
22
+
23
+ If you find my open-source contributions or the **<%- projectName %>** project helpful, consider supporting my work. Your sponsorship helps me maintain these projects and explore new enterprise patterns.
24
+
25
+ [![CashApp](https://img.shields.io/badge/Sponsor%20me-%23EA4AAA.svg?style=for-the-badge&logo=github-sponsors&logoColor=white)](<%- funding %>)
26
+
27
+ ---
28
+
29
+ ## 🤝 Connect with Me
30
+
31
+ <p align="left">
32
+ <a href="mailto:<%- email %>">
33
+ <img src="https://img.shields.io/badge/Email-D14836?style=for-the-badge&logo=gmail&logoColor=white" />
34
+ </a>
35
+ </p>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ console.log("<%- fileName %>")
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "<%- projectName %>",
3
+ "version": "<%- version %>",
4
+ "description": "<%- projectName %>",
5
+ "keywords": [
6
+ "<%- fileName %>"
7
+ ],
8
+ "author": {
9
+ "name": "<%- author %>",
10
+ "email": "<%- email %>",
11
+ "url": "<%- homepage %>"
12
+ },
13
+ "homepage": "<%- homepage %>/<%- directory %>",
14
+ "icon": "<%- homepage %>/<%- directory %>/assets/favicon.png",
15
+ "funding": [
16
+ "<%- funding %>"
17
+ ],
18
+ "bin": {
19
+ "<%- fileName %>": "./bin/<%- fileName %>.mjs"
20
+ },
21
+ "main": "./dist/index.js",
22
+ "module": "./dist/index.js",
23
+ "types": "./dist/index.d.ts",
24
+ "exports": {
25
+ "./package.json": "./package.json",
26
+ ".": {
27
+ "@<%- orgname %>/source": "./src/index.ts",
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js",
30
+ "default": "./dist/index.js"
31
+ }
32
+ },
33
+ "files": [
34
+ "dist",
35
+ "bin",
36
+ "assets",
37
+ "scripts",
38
+ "!**/*.tsbuildinfo"
39
+ ],
40
+ "nx": {
41
+ "sourceRoot": "<%- directory %>/src",
42
+ "tags": [
43
+ "app"
44
+ ],
45
+ "targets": {
46
+ "build": {
47
+ "options": {
48
+ "main": "{projectRoot}/src/main.cts"
49
+ }
50
+ },
51
+ "build-script": {},
52
+ "doc": {},
53
+ "lint": {},
54
+ "serve": {}
55
+ }
56
+ },
57
+ "dependencies": {
58
+ "@swc/helpers": "~0.5.18"
59
+ },
60
+ "devDependencies": {
61
+ "@nestjs/testing": "^11.1.18",
62
+ "@types/supertest": "^7.2.0",
63
+ "@vnodes/autowire": "workspace:*",
64
+ "@vnodes/boot-fastify": "workspace:*",
65
+ "@vnodes/nestjs": "workspace:*",
66
+ "@vnodes/nestjs-common": "workspace:*",
67
+ "@vnodes/types": "^0.0.23",
68
+ "supertest": "^7.2.2"
69
+ },
70
+ "peerDependencies": {
71
+ "@vnodes/autowire": "workspace:*",
72
+ "@vnodes/boot-fastify": "workspace:*",
73
+ "@vnodes/nestjs": "workspace:*",
74
+ "@vnodes/nestjs-common": "workspace:*"
75
+ }
76
+ }
@@ -0,0 +1 @@
1
+ console.log("There is nothing to run in build script")
@@ -0,0 +1,39 @@
1
+ import { Test } from '@nestjs/testing';
2
+ import type { INestApplication } from '@vnodes/nestjs/common';
3
+ import type { Any } from '@vnodes/types';
4
+ import request from 'supertest';
5
+ import { AppController } from './app.controller';
6
+ import { AppService } from './app.service';
7
+
8
+ describe('AppController', () => {
9
+
10
+ let app: INestApplication;
11
+ const appService: Record<keyof AppService, () => Any> = {
12
+ hello() {
13
+ return { test: 'test' };
14
+ },
15
+ };
16
+
17
+ beforeAll(async () => {
18
+ const moduleRef = await Test.createTestingModule({
19
+ controllers: [AppController],
20
+ providers: [AppService],
21
+ })
22
+ .overrideProvider(AppService)
23
+ .useValue(appService)
24
+ .compile();
25
+
26
+ app = moduleRef.createNestApplication();
27
+ await app.init();
28
+ });
29
+
30
+ it(`/GET hello`, async () => {
31
+ const res = await request(app.getHttpServer()).get('/hello');
32
+ expect(res.status).toBe(200);
33
+ expect(res.body).toEqual(appService.hello());
34
+ });
35
+
36
+ afterAll(async () => {
37
+ await app.close();
38
+ });
39
+ });
@@ -0,0 +1,12 @@
1
+ /** biome-ignore-all lint/style/useImportType: DI */
2
+ import { Controller, Get, Inject } from '@vnodes/nestjs/common';
3
+ import { AppService } from './app.service';
4
+
5
+ @Controller()
6
+ export class AppController {
7
+ constructor(@Inject(AppService) protected readonly appService: AppService) {}
8
+ @Get('hello')
9
+ hello() {
10
+ return this.appService.hello();
11
+ }
12
+ }
@@ -0,0 +1,11 @@
1
+ import { Module } from '@vnodes/nestjs/common';
2
+ import { CommonAppModule } from '@vnodes/nestjs-common';
3
+ import { AppController } from './app.controller.js';
4
+ import { AppService } from './app.service.js';
5
+
6
+ @Module({
7
+ imports: [CommonAppModule],
8
+ controllers: [AppController],
9
+ providers: [AppService],
10
+ })
11
+ export class AppModule {}
@@ -0,0 +1,10 @@
1
+ import { Injectable } from '@vnodes/nestjs/common';
2
+
3
+ @Injectable()
4
+ export class AppService {
5
+ hello() {
6
+ return {
7
+ message: 'hello',
8
+ };
9
+ }
10
+ }
@@ -0,0 +1,4 @@
1
+ // @index(['./**/*.ts', '!./**/*.{spec,test}.ts', '!./src/main.ts'], f => `export * from '${f.path}.js'`)
2
+ export * from './app.controller.js';
3
+ export * from './app.module.js';
4
+ export * from './main.js';
@@ -0,0 +1,6 @@
1
+ import { boot } from '@vnodes/boot-fastify';
2
+ import { AppModule } from './app.module.js';
3
+
4
+ export async function main() {
5
+ await boot({ module: AppModule });
6
+ }
@@ -0,0 +1,3 @@
1
+ import { main } from '../main.js';
2
+
3
+ main();
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "files": [],
4
+ "include": [],
5
+ "references": [
6
+ {
7
+ "path": "./tsconfig.lib.json"
8
+ },
9
+ {
10
+ "path": "./tsconfig.spec.json"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist",
6
+ "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
7
+ "emitDeclarationOnly": true,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "types": ["node"]
10
+ },
11
+ "include": ["src/**/*.ts"],
12
+ "references": [],
13
+ "exclude": ["vitest.config.mts", "src/**/*.spec.ts"]
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./out-tsc/vitest",
5
+ "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node", "vitest"],
6
+ "forceConsistentCasingInFileNames": true
7
+ },
8
+ "include": ["vitest.config.mts", "src/**/*.spec.ts"],
9
+ "references": [
10
+ {
11
+ "path": "./tsconfig.lib.json"
12
+ }
13
+ ]
14
+ }
@@ -0,0 +1,18 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig(() => ({
4
+ root: __dirname,
5
+ cacheDir: '../../node_modules/.vite/<%- directory %>',
6
+ test: {
7
+ name: '<%- projectName %>',
8
+ watch: false,
9
+ globals: true,
10
+ environment: 'node',
11
+ include: ['src/**/*.spec.ts'],
12
+ reporters: ['default'],
13
+ coverage: {
14
+ reportsDirectory: './test-output/vitest/coverage',
15
+ provider: 'v8' as const,
16
+ },
17
+ },
18
+ }));
@@ -0,0 +1,4 @@
1
+ APP_ID=<%- fileName %>
2
+ APP_DESC=<%- fileName %>
3
+ DB_URL=postgres://admin:password@localhost:5432/<%- orgname %>?schema=<%- fileName %>
4
+ DB_SCHEMA=<%- fileName %>
@@ -0,0 +1,28 @@
1
+ {
2
+ "jsc": {
3
+ "target": "es2021",
4
+ "parser": {
5
+ "syntax": "typescript",
6
+ "decorators": true,
7
+ "dynamicImport": true
8
+ },
9
+ "transform": {
10
+ "decoratorMetadata": true,
11
+ "legacyDecorator": true,
12
+ "useDefineForClassFields": true
13
+ },
14
+ "keepClassNames": true,
15
+ "externalHelpers": true,
16
+ "loose": false
17
+ },
18
+ "module": {
19
+ "type": "commonjs",
20
+ "noInterop": false
21
+ },
22
+ "sourceMaps": true,
23
+ "exclude": [
24
+ "vitest.config.mts",
25
+ ".*\\.spec.ts$",
26
+ ".*.js$"
27
+ ]
28
+ }
@@ -0,0 +1,35 @@
1
+ ![Npm version](https://img.shields.io/npm/v/<%- projectName %>)
2
+ ![Npm downloads](https://img.shields.io/npm/dm/<%- projectName %>)
3
+ ![Build Status](https://img.shields.io/github/actions/workflow/status/<%- orgname %>/<%- reponame %>/ci.yml)
4
+ ![Doc Status](https://img.shields.io/github/actions/workflow/status/<%- orgname %>/<%- reponame %>/doc.yml)
5
+ ![Bundle size](https://img.shields.io/bundlephobia/min/<%- projectName %>)
6
+
7
+ <p align="center">
8
+ <img srcset="./assets/favicon.png, <%- homepage %>/<%- directory %>/assets/favicon.png" alt="Logo" width="200" height="200" style="border-radius: 100%"/>
9
+ </p>
10
+
11
+ ## <%- projectName %>
12
+
13
+ Rest Api | <%- projectName %>
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pnpm add <%- projectName %>
19
+ ```
20
+
21
+ ## 💖 Support My Work
22
+
23
+ If you find my open-source contributions or the **<%- projectName %>** project helpful, consider supporting my work. Your sponsorship helps me maintain these projects and explore new enterprise patterns.
24
+
25
+ [![CashApp](https://img.shields.io/badge/Sponsor%20me-%23EA4AAA.svg?style=for-the-badge&logo=github-sponsors&logoColor=white)](<%- funding %>)
26
+
27
+ ---
28
+
29
+ ## 🤝 Connect with Me
30
+
31
+ <p align="left">
32
+ <a href="mailto:<%- email %>">
33
+ <img src="https://img.shields.io/badge/Email-D14836?style=for-the-badge&logo=gmail&logoColor=white" />
34
+ </a>
35
+ </p>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ console.log("<%- fileName %>")
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "<%- projectName %>",
3
+ "version": "<%- version %>",
4
+ "description": "<%- projectName %>",
5
+ "keywords": [
6
+ "<%- fileName %>"
7
+ ],
8
+ "author": {
9
+ "name": "<%- author %>",
10
+ "email": "<%- email %>",
11
+ "url": "<%- homepage %>"
12
+ },
13
+ "homepage": "<%- homepage %>/<%- directory %>",
14
+ "icon": "<%- homepage %>/<%- directory %>/assets/favicon.png",
15
+ "funding": [
16
+ "<%- funding %>"
17
+ ],
18
+ "bin": {
19
+ "<%- fileName %>": "./bin/<%- fileName %>.mjs"
20
+ },
21
+ "main": "./dist/index.js",
22
+ "module": "./dist/index.js",
23
+ "types": "./dist/index.d.ts",
24
+ "exports": {
25
+ "./package.json": "./package.json",
26
+ ".": {
27
+ "@<%- orgname %>/source": "./src/index.ts",
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js",
30
+ "default": "./dist/index.js"
31
+ }
32
+ },
33
+ "files": [
34
+ "dist",
35
+ "bin",
36
+ "assets",
37
+ "scripts",
38
+ "!**/*.tsbuildinfo"
39
+ ],
40
+ "nx": {
41
+ "sourceRoot": "<%- directory %>/src",
42
+ "tags": [
43
+ "app"
44
+ ],
45
+ "targets": {
46
+ "build": {
47
+ "options": {
48
+ "main": "{projectRoot}/src/main.cts"
49
+ }
50
+ },
51
+ "build-script": {},
52
+ "doc": {},
53
+ "lint": {},
54
+ "serve": {}
55
+ }
56
+ },
57
+ "dependencies": {
58
+ "@swc/helpers": "~0.5.18"
59
+ },
60
+
61
+ "devDependencies": {
62
+ "@nestjs/testing": "^11.1.18",
63
+ "@types/supertest": "^7.2.0",
64
+ "@vnodes/autowire": "workspace:*",
65
+ "@vnodes/boot-express": "workspace:*",
66
+ "@vnodes/graphql": "workspace:*",
67
+ "@vnodes/nestjs": "workspace:*",
68
+ "@vnodes/nestjs-common": "workspace:*",
69
+ "@vnodes/types": "^0.0.23",
70
+ "supertest": "^7.2.2"
71
+ },
72
+ "peerDependencies": {
73
+ "@vnodes/autowire": "workspace:*",
74
+ "@vnodes/boot-express": "workspace:*",
75
+ "@vnodes/boot-fastify": "workspace:*",
76
+ "@vnodes/graphql": "workspace:*",
77
+ "@vnodes/nestjs": "workspace:*",
78
+ "@vnodes/nestjs-common": "workspace:*"
79
+ }
80
+ }
@@ -0,0 +1 @@
1
+ console.log("There is nothing to run in build script")
@@ -0,0 +1,39 @@
1
+ import { Test } from '@nestjs/testing';
2
+ import type { INestApplication } from '@vnodes/nestjs/common';
3
+ import type { Any } from '@vnodes/types';
4
+ import request from 'supertest';
5
+ import { AppController } from './app.controller';
6
+ import { AppService } from './app.service';
7
+
8
+ describe('AppController', () => {
9
+
10
+ let app: INestApplication;
11
+ const appService: Record<keyof AppService, () => Any> = {
12
+ hello() {
13
+ return { test: 'test' };
14
+ },
15
+ };
16
+
17
+ beforeAll(async () => {
18
+ const moduleRef = await Test.createTestingModule({
19
+ controllers: [AppController],
20
+ providers: [AppService],
21
+ })
22
+ .overrideProvider(AppService)
23
+ .useValue(appService)
24
+ .compile();
25
+
26
+ app = moduleRef.createNestApplication();
27
+ await app.init();
28
+ });
29
+
30
+ it(`/GET hello`, async () => {
31
+ const res = await request(app.getHttpServer()).get('/hello');
32
+ expect(res.status).toBe(200);
33
+ expect(res.body).toEqual(appService.hello());
34
+ });
35
+
36
+ afterAll(async () => {
37
+ await app.close();
38
+ });
39
+ });
@@ -0,0 +1,12 @@
1
+ /** biome-ignore-all lint/style/useImportType: DI */
2
+ import { Controller, Get, Inject } from '@vnodes/nestjs/common';
3
+ import { AppService } from './app.service';
4
+
5
+ @Controller()
6
+ export class AppController {
7
+ constructor(@Inject(AppService) protected readonly appService: AppService) {}
8
+ @Get('hello')
9
+ hello() {
10
+ return this.appService.hello();
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ import { Module } from '@vnodes/nestjs/common';
2
+ import { CommonGrapqlModule } from '@vnodes/nestjs-common';
3
+ import { AppController } from './app.controller.js';
4
+ import { AppService } from './app.service.js';
5
+ import { ResourceModule } from './resources/resource.module.js';
6
+
7
+ @Module({
8
+ imports: [CommonGrapqlModule, ResourceModule],
9
+ controllers: [AppController],
10
+ providers: [AppService],
11
+ })
12
+ export class AppModule {}
@@ -0,0 +1,10 @@
1
+ import { Injectable } from '@vnodes/nestjs/common';
2
+
3
+ @Injectable()
4
+ export class AppService {
5
+ hello() {
6
+ return {
7
+ message: 'hello',
8
+ };
9
+ }
10
+ }
@@ -0,0 +1,4 @@
1
+ // @index(['./**/*.ts', '!./**/*.{spec,test}.ts', '!./src/main.ts'], f => `export * from '${f.path}.js'`)
2
+ export * from './app.controller.js';
3
+ export * from './app.module.js';
4
+ export * from './main.js';
@@ -0,0 +1,6 @@
1
+ import { boot } from '@vnodes/boot-express';
2
+ import { AppModule } from './app.module.js';
3
+
4
+ export async function main() {
5
+ await boot({ module: AppModule, graphql: true }, {}, []);
6
+ }
@@ -0,0 +1,7 @@
1
+ import { Module } from '@vnodes/nestjs/common';
2
+ import { SampleModule } from './sample/sample.module';
3
+
4
+ @Module({
5
+ imports: [SampleModule],
6
+ })
7
+ export class ResourceModule {}
@@ -0,0 +1,16 @@
1
+ import { InputType, PartialType, Prop } from '@vnodes/graphql';
2
+
3
+ @InputType()
4
+ export class SampleCreateInput {
5
+ @Prop({ maximum: 50, required: true })
6
+ title: string;
7
+
8
+ @Prop({ minimum: 30, maximum: 400 })
9
+ description?: string;
10
+
11
+ @Prop({}, () => [String])
12
+ ingredients: string[];
13
+ }
14
+
15
+ @InputType()
16
+ export class SampleUpdateInput extends PartialType(SampleCreateInput) {}
@@ -0,0 +1,23 @@
1
+ import { ObjectType, Prop } from '@vnodes/graphql';
2
+
3
+ @ObjectType({ description: 'samples' })
4
+ export class SampleModel {
5
+ @Prop()
6
+ id?: string = '1';
7
+
8
+ @Prop()
9
+ title?: string = 'Defautl title';
10
+
11
+ @Prop()
12
+ description?: string = 'Default description';
13
+
14
+ @Prop()
15
+ creationDate?: Date = new Date();
16
+
17
+ @Prop({}, () => [String])
18
+ ingredients: string[] = [];
19
+
20
+ constructor(data: Partial<SampleModel> = {}) {
21
+ Object.assign(this, data);
22
+ }
23
+ }
@@ -0,0 +1,10 @@
1
+ import { ArgsType, Prop } from '@vnodes/graphql';
2
+
3
+ @ArgsType()
4
+ export class SampleQueryArgs {
5
+ @Prop({ minimum: 0 })
6
+ skip: number = 0;
7
+
8
+ @Prop({ minimum: 1 })
9
+ take: number = 25;
10
+ }
@@ -0,0 +1,7 @@
1
+ import { Module } from '@vnodes/nestjs/common';
2
+ import { SamplesResolver } from './sample.resolver';
3
+
4
+ @Module({
5
+ providers: [SamplesResolver],
6
+ })
7
+ export class SampleModule {}
@@ -0,0 +1,45 @@
1
+ /** biome-ignore-all lint/style/useImportType: DI */
2
+
3
+ import { Args, Mutation, PubSub, Query, Resolver, Subscription } from '@vnodes/graphql';
4
+ import type { Any } from '@vnodes/types';
5
+ import { SampleCreateInput, SampleUpdateInput } from './models/sample-create.input.js';
6
+ import { SampleModel } from './models/sample-model.js';
7
+ import { SampleQueryArgs } from './models/sample-query.args.js';
8
+
9
+ const pubSub = new PubSub();
10
+
11
+ @Resolver(() => SampleModel)
12
+ export class SamplesResolver {
13
+ @Query(() => SampleModel)
14
+ async findSampleById(@Args('id') id: string) {
15
+ return new SampleModel({ id });
16
+ }
17
+
18
+ @Query(() => [SampleModel])
19
+ async findManySample(@Args() sampleArgs: SampleQueryArgs) {
20
+ return [new SampleModel(), new SampleModel()];
21
+ }
22
+
23
+ @Mutation(() => SampleModel)
24
+ async createSample(@Args('sample') data: SampleCreateInput) {
25
+ const result = new SampleModel(data);
26
+ await pubSub.publish('sampleAdded', { sampleAdded: result });
27
+
28
+ return result;
29
+ }
30
+
31
+ @Mutation(() => SampleModel)
32
+ async deleteSampleById(@Args('id') id: string) {
33
+ return { id };
34
+ }
35
+
36
+ @Mutation(() => SampleModel)
37
+ async udpatesample(@Args('id') id: string, @Args('sample') data: SampleUpdateInput) {
38
+ return { id };
39
+ }
40
+
41
+ @Subscription(() => SampleModel)
42
+ sampleAdded(): Any {
43
+ return pubSub.asyncIterableIterator('sampleAdded');
44
+ }
45
+ }
@@ -0,0 +1,3 @@
1
+ import { main } from '../main.js';
2
+
3
+ main();
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "files": [],
4
+ "include": [],
5
+ "references": [
6
+ {
7
+ "path": "./tsconfig.lib.json"
8
+ },
9
+ {
10
+ "path": "./tsconfig.spec.json"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist",
6
+ "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
7
+ "emitDeclarationOnly": true,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "types": ["node"]
10
+ },
11
+ "include": ["src/**/*.ts"],
12
+ "references": [],
13
+ "exclude": ["vitest.config.mts", "src/**/*.spec.ts"]
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./out-tsc/vitest",
5
+ "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node", "vitest"],
6
+ "forceConsistentCasingInFileNames": true
7
+ },
8
+ "include": ["vitest.config.mts", "src/**/*.spec.ts"],
9
+ "references": [
10
+ {
11
+ "path": "./tsconfig.lib.json"
12
+ }
13
+ ]
14
+ }
@@ -0,0 +1,18 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig(() => ({
4
+ root: __dirname,
5
+ cacheDir: '../../node_modules/.vite/<%- directory %>',
6
+ test: {
7
+ name: '<%- projectName %>',
8
+ watch: false,
9
+ globals: true,
10
+ environment: 'node',
11
+ include: ['src/**/*.spec.ts'],
12
+ reporters: ['default'],
13
+ coverage: {
14
+ reportsDirectory: './test-output/vitest/coverage',
15
+ provider: 'v8' as const,
16
+ },
17
+ },
18
+ }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnodes/plugin",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",