u
This commit is contained in:
1 parent
19b160620f
commit
835958886e
47 files changed
+9573
No files matched your search
@@ -0,0 +1,56 @@
|
||||
# compiled output
|
||||
/dist
|
||||
/node_modules
|
||||
/build
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
pnpm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
|
||||
# Tests
|
||||
/coverage
|
||||
/.nyc_output
|
||||
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
|
||||
# IDE - VSCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# temp directory
|
||||
.temp
|
||||
.tmp
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
{
|
||||
// Disable the default formatter, use eslint instead
|
||||
"prettier.enable": false,
|
||||
"editor.formatOnSave": false,
|
||||
|
||||
// Auto fix
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": "explicit",
|
||||
"source.organizeImports": "never"
|
||||
},
|
||||
|
||||
// Silent the stylistic rules in your IDE, but still auto fix them
|
||||
"eslint.rules.customizations": [
|
||||
{ "rule": "style/*", "severity": "off", "fixable": true },
|
||||
{ "rule": "format/*", "severity": "off", "fixable": true },
|
||||
{ "rule": "*-indent", "severity": "off", "fixable": true },
|
||||
{ "rule": "*-spacing", "severity": "off", "fixable": true },
|
||||
{ "rule": "*-spaces", "severity": "off", "fixable": true },
|
||||
{ "rule": "*-order", "severity": "off", "fixable": true },
|
||||
{ "rule": "*-dangle", "severity": "off", "fixable": true },
|
||||
{ "rule": "*-newline", "severity": "off", "fixable": true },
|
||||
{ "rule": "*quotes", "severity": "off", "fixable": true },
|
||||
{ "rule": "*semi", "severity": "off", "fixable": true }
|
||||
],
|
||||
|
||||
// Enable eslint for all supported languages
|
||||
"eslint.validate": [
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"vue",
|
||||
"html",
|
||||
"markdown",
|
||||
"json",
|
||||
"json5",
|
||||
"jsonc",
|
||||
"yaml",
|
||||
"toml",
|
||||
"xml",
|
||||
"gql",
|
||||
"graphql",
|
||||
"astro",
|
||||
"svelte",
|
||||
"css",
|
||||
"less",
|
||||
"scss",
|
||||
"pcss",
|
||||
"postcss"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
||||
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
||||
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||||
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
|
||||
</p>
|
||||
<!--[](https://opencollective.com/nest#backer)
|
||||
[](https://opencollective.com/nest#sponsor)-->
|
||||
|
||||
## Description
|
||||
|
||||
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
||||
|
||||
## Project setup
|
||||
|
||||
```bash
|
||||
$ pnpm install
|
||||
```
|
||||
|
||||
## Compile and run the project
|
||||
|
||||
```bash
|
||||
# development
|
||||
$ pnpm run start
|
||||
|
||||
# watch mode
|
||||
$ pnpm run start:dev
|
||||
|
||||
# production mode
|
||||
$ pnpm run start:prod
|
||||
```
|
||||
|
||||
## Run tests
|
||||
|
||||
```bash
|
||||
# unit tests
|
||||
$ pnpm run test
|
||||
|
||||
# e2e tests
|
||||
$ pnpm run test:e2e
|
||||
|
||||
# test coverage
|
||||
$ pnpm run test:cov
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information.
|
||||
|
||||
If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
|
||||
|
||||
```bash
|
||||
$ pnpm install -g @nestjs/mau
|
||||
$ mau deploy
|
||||
```
|
||||
|
||||
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
|
||||
|
||||
## Resources
|
||||
|
||||
Check out a few resources that may come in handy when working with NestJS:
|
||||
|
||||
- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
|
||||
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
|
||||
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
|
||||
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
|
||||
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
|
||||
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
|
||||
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
|
||||
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
|
||||
|
||||
## Support
|
||||
|
||||
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
||||
|
||||
## Stay in touch
|
||||
|
||||
- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
|
||||
- Website - [https://nestjs.com](https://nestjs.com/)
|
||||
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
||||
|
||||
## License
|
||||
|
||||
Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'dotenv/config';
|
||||
import { defineConfig } from 'drizzle-kit';
|
||||
import { loadConfig } from './src/config/loader';
|
||||
|
||||
const config = loadConfig();
|
||||
|
||||
export default defineConfig({
|
||||
out: './drizzle',
|
||||
schema: './src/db/schema',
|
||||
dialect: 'postgresql',
|
||||
dbCredentials: {
|
||||
host: config.db.host,
|
||||
port: config.db.port,
|
||||
user: config.db.user,
|
||||
password: config.db.password,
|
||||
database: config.db.dbname,
|
||||
ssl: config.db.ssl_mode || false,
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,124 @@
|
||||
CREATE TABLE "finance_category_default" (
|
||||
"id" bigint PRIMARY KEY NOT NULL,
|
||||
"name" varchar(64) NOT NULL,
|
||||
"icon" varchar(64) NOT NULL,
|
||||
"type" smallint DEFAULT 0 NOT NULL,
|
||||
"sort_number" integer DEFAULT 0 NOT NULL,
|
||||
"create_time" timestamp with time zone DEFAULT now(),
|
||||
"update_time" timestamp with time zone DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "finance_category_space" (
|
||||
"id" bigint PRIMARY KEY NOT NULL,
|
||||
"space_id" bigint NOT NULL,
|
||||
"name" varchar(64) NOT NULL,
|
||||
"icon" varchar(64) NOT NULL,
|
||||
"type" smallint DEFAULT 0 NOT NULL,
|
||||
"sort_number" integer DEFAULT 0 NOT NULL,
|
||||
"create_by" bigint NOT NULL,
|
||||
"create_time" timestamp with time zone DEFAULT now(),
|
||||
"update_by" bigint NOT NULL,
|
||||
"update_time" timestamp with time zone DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "finance_record" (
|
||||
"id" bigint PRIMARY KEY NOT NULL,
|
||||
"category_id" bigint NOT NULL,
|
||||
"space_id" bigint NOT NULL,
|
||||
"amount" numeric(12, 2) NOT NULL,
|
||||
"remark" varchar(255),
|
||||
"record_time" date,
|
||||
"create_by" bigint NOT NULL,
|
||||
"create_time" timestamp with time zone DEFAULT now(),
|
||||
"update_by" bigint NOT NULL,
|
||||
"update_time" timestamp with time zone DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "session" (
|
||||
"id" bigint PRIMARY KEY NOT NULL,
|
||||
"space_id" bigint NOT NULL,
|
||||
"type" smallint DEFAULT 0 NOT NULL,
|
||||
"name" varchar(64),
|
||||
"avatar" varchar(255),
|
||||
"description" text,
|
||||
"status" smallint DEFAULT 0 NOT NULL,
|
||||
"create_time" timestamp with time zone DEFAULT now(),
|
||||
"update_time" timestamp with time zone DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "session_member" (
|
||||
"id" bigint PRIMARY KEY NOT NULL,
|
||||
"session_id" bigint NOT NULL,
|
||||
"user_id" bigint NOT NULL,
|
||||
"remark" varchar(255),
|
||||
"is_top" smallint DEFAULT 0 NOT NULL,
|
||||
"unread_count" integer DEFAULT 0,
|
||||
"last_msg_id" bigint,
|
||||
"status" integer DEFAULT 0,
|
||||
"create_time" timestamp with time zone DEFAULT now(),
|
||||
"update_time" timestamp with time zone DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "session_message" (
|
||||
"id" bigint PRIMARY KEY NOT NULL,
|
||||
"session_id" bigint NOT NULL,
|
||||
"sender_id" bigint NOT NULL,
|
||||
"content" text NOT NULL,
|
||||
"content_type" smallint DEFAULT 0 NOT NULL,
|
||||
"create_time" timestamp with time zone DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "space" (
|
||||
"id" bigint PRIMARY KEY NOT NULL,
|
||||
"name" varchar(255) NOT NULL,
|
||||
"invite_code" varchar(30) NOT NULL,
|
||||
"owner_id" bigint NOT NULL,
|
||||
"create_time" timestamp with time zone DEFAULT now(),
|
||||
"update_time" timestamp with time zone DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "space_member" (
|
||||
"id" bigint PRIMARY KEY NOT NULL,
|
||||
"space_id" bigint NOT NULL,
|
||||
"user_id" bigint NOT NULL,
|
||||
"role" smallint DEFAULT 2 NOT NULL,
|
||||
"join_time" timestamp with time zone DEFAULT now(),
|
||||
"update_time" timestamp with time zone DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "user" (
|
||||
"id" bigint PRIMARY KEY NOT NULL,
|
||||
"nickname" varchar(255),
|
||||
"avatar" varchar(255),
|
||||
"status" smallint DEFAULT 0 NOT NULL,
|
||||
"last_login_time" timestamp with time zone,
|
||||
"create_time" timestamp with time zone DEFAULT now(),
|
||||
"update_time" timestamp with time zone DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "user_oauth" (
|
||||
"id" bigint PRIMARY KEY NOT NULL,
|
||||
"user_id" bigint NOT NULL,
|
||||
"type" smallint DEFAULT 0 NOT NULL,
|
||||
"openid" varchar(255) NOT NULL,
|
||||
"create_time" timestamp with time zone DEFAULT now(),
|
||||
"update_time" timestamp with time zone DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "finance_category_space" ADD CONSTRAINT "finance_category_space_space_id_space_id_fk" FOREIGN KEY ("space_id") REFERENCES "public"."space"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "finance_category_space" ADD CONSTRAINT "finance_category_space_create_by_user_id_fk" FOREIGN KEY ("create_by") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "finance_category_space" ADD CONSTRAINT "finance_category_space_update_by_user_id_fk" FOREIGN KEY ("update_by") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "finance_record" ADD CONSTRAINT "finance_record_category_id_finance_category_space_id_fk" FOREIGN KEY ("category_id") REFERENCES "public"."finance_category_space"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "finance_record" ADD CONSTRAINT "finance_record_space_id_space_id_fk" FOREIGN KEY ("space_id") REFERENCES "public"."space"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "finance_record" ADD CONSTRAINT "finance_record_create_by_user_id_fk" FOREIGN KEY ("create_by") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "finance_record" ADD CONSTRAINT "finance_record_update_by_user_id_fk" FOREIGN KEY ("update_by") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "session" ADD CONSTRAINT "session_space_id_space_id_fk" FOREIGN KEY ("space_id") REFERENCES "public"."space"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "session_member" ADD CONSTRAINT "session_member_session_id_session_id_fk" FOREIGN KEY ("session_id") REFERENCES "public"."session"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "session_member" ADD CONSTRAINT "session_member_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "session_member" ADD CONSTRAINT "session_member_last_msg_id_session_message_id_fk" FOREIGN KEY ("last_msg_id") REFERENCES "public"."session_message"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "session_message" ADD CONSTRAINT "session_message_session_id_session_id_fk" FOREIGN KEY ("session_id") REFERENCES "public"."session"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "session_message" ADD CONSTRAINT "session_message_sender_id_user_id_fk" FOREIGN KEY ("sender_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "space" ADD CONSTRAINT "space_owner_id_user_id_fk" FOREIGN KEY ("owner_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "space_member" ADD CONSTRAINT "space_member_space_id_space_id_fk" FOREIGN KEY ("space_id") REFERENCES "public"."space"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "space_member" ADD CONSTRAINT "space_member_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "user_oauth" ADD CONSTRAINT "user_oauth_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;
|
||||
@@ -0,0 +1,872 @@
|
||||
{
|
||||
"id": "95ee35f9-43d8-4df6-b2ff-f598eaf78113",
|
||||
"prevId": "00000000-0000-0000-0000-000000000000",
|
||||
"version": "7",
|
||||
"dialect": "postgresql",
|
||||
"tables": {
|
||||
"public.finance_category_default": {
|
||||
"name": "finance_category_default",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "bigint",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "varchar(64)",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"icon": {
|
||||
"name": "icon",
|
||||
"type": "varchar(64)",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"type": {
|
||||
"name": "type",
|
||||
"type": "smallint",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 0
|
||||
},
|
||||
"sort_number": {
|
||||
"name": "sort_number",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 0
|
||||
},
|
||||
"create_time": {
|
||||
"name": "create_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"update_time": {
|
||||
"name": "update_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.finance_category_space": {
|
||||
"name": "finance_category_space",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "bigint",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"space_id": {
|
||||
"name": "space_id",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "varchar(64)",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"icon": {
|
||||
"name": "icon",
|
||||
"type": "varchar(64)",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"type": {
|
||||
"name": "type",
|
||||
"type": "smallint",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 0
|
||||
},
|
||||
"sort_number": {
|
||||
"name": "sort_number",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 0
|
||||
},
|
||||
"create_by": {
|
||||
"name": "create_by",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"create_time": {
|
||||
"name": "create_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"update_by": {
|
||||
"name": "update_by",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"update_time": {
|
||||
"name": "update_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"finance_category_space_space_id_space_id_fk": {
|
||||
"name": "finance_category_space_space_id_space_id_fk",
|
||||
"tableFrom": "finance_category_space",
|
||||
"tableTo": "space",
|
||||
"columnsFrom": [
|
||||
"space_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"finance_category_space_create_by_user_id_fk": {
|
||||
"name": "finance_category_space_create_by_user_id_fk",
|
||||
"tableFrom": "finance_category_space",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"create_by"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"finance_category_space_update_by_user_id_fk": {
|
||||
"name": "finance_category_space_update_by_user_id_fk",
|
||||
"tableFrom": "finance_category_space",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"update_by"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.finance_record": {
|
||||
"name": "finance_record",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "bigint",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"category_id": {
|
||||
"name": "category_id",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"space_id": {
|
||||
"name": "space_id",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"amount": {
|
||||
"name": "amount",
|
||||
"type": "numeric(12, 2)",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"remark": {
|
||||
"name": "remark",
|
||||
"type": "varchar(255)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"record_time": {
|
||||
"name": "record_time",
|
||||
"type": "date",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"create_by": {
|
||||
"name": "create_by",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"create_time": {
|
||||
"name": "create_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"update_by": {
|
||||
"name": "update_by",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"update_time": {
|
||||
"name": "update_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"finance_record_category_id_finance_category_space_id_fk": {
|
||||
"name": "finance_record_category_id_finance_category_space_id_fk",
|
||||
"tableFrom": "finance_record",
|
||||
"tableTo": "finance_category_space",
|
||||
"columnsFrom": [
|
||||
"category_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"finance_record_space_id_space_id_fk": {
|
||||
"name": "finance_record_space_id_space_id_fk",
|
||||
"tableFrom": "finance_record",
|
||||
"tableTo": "space",
|
||||
"columnsFrom": [
|
||||
"space_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"finance_record_create_by_user_id_fk": {
|
||||
"name": "finance_record_create_by_user_id_fk",
|
||||
"tableFrom": "finance_record",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"create_by"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"finance_record_update_by_user_id_fk": {
|
||||
"name": "finance_record_update_by_user_id_fk",
|
||||
"tableFrom": "finance_record",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"update_by"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.session": {
|
||||
"name": "session",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "bigint",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"space_id": {
|
||||
"name": "space_id",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"type": {
|
||||
"name": "type",
|
||||
"type": "smallint",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 0
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "varchar(64)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"avatar": {
|
||||
"name": "avatar",
|
||||
"type": "varchar(255)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"description": {
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"status": {
|
||||
"name": "status",
|
||||
"type": "smallint",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 0
|
||||
},
|
||||
"create_time": {
|
||||
"name": "create_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"update_time": {
|
||||
"name": "update_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"session_space_id_space_id_fk": {
|
||||
"name": "session_space_id_space_id_fk",
|
||||
"tableFrom": "session",
|
||||
"tableTo": "space",
|
||||
"columnsFrom": [
|
||||
"space_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.session_member": {
|
||||
"name": "session_member",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "bigint",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"session_id": {
|
||||
"name": "session_id",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"remark": {
|
||||
"name": "remark",
|
||||
"type": "varchar(255)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"is_top": {
|
||||
"name": "is_top",
|
||||
"type": "smallint",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 0
|
||||
},
|
||||
"unread_count": {
|
||||
"name": "unread_count",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": 0
|
||||
},
|
||||
"last_msg_id": {
|
||||
"name": "last_msg_id",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"status": {
|
||||
"name": "status",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": 0
|
||||
},
|
||||
"create_time": {
|
||||
"name": "create_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"update_time": {
|
||||
"name": "update_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"session_member_session_id_session_id_fk": {
|
||||
"name": "session_member_session_id_session_id_fk",
|
||||
"tableFrom": "session_member",
|
||||
"tableTo": "session",
|
||||
"columnsFrom": [
|
||||
"session_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"session_member_user_id_user_id_fk": {
|
||||
"name": "session_member_user_id_user_id_fk",
|
||||
"tableFrom": "session_member",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"session_member_last_msg_id_session_message_id_fk": {
|
||||
"name": "session_member_last_msg_id_session_message_id_fk",
|
||||
"tableFrom": "session_member",
|
||||
"tableTo": "session_message",
|
||||
"columnsFrom": [
|
||||
"last_msg_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.session_message": {
|
||||
"name": "session_message",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "bigint",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"session_id": {
|
||||
"name": "session_id",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"sender_id": {
|
||||
"name": "sender_id",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"content": {
|
||||
"name": "content",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"content_type": {
|
||||
"name": "content_type",
|
||||
"type": "smallint",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 0
|
||||
},
|
||||
"create_time": {
|
||||
"name": "create_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"session_message_session_id_session_id_fk": {
|
||||
"name": "session_message_session_id_session_id_fk",
|
||||
"tableFrom": "session_message",
|
||||
"tableTo": "session",
|
||||
"columnsFrom": [
|
||||
"session_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"session_message_sender_id_user_id_fk": {
|
||||
"name": "session_message_sender_id_user_id_fk",
|
||||
"tableFrom": "session_message",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"sender_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.space": {
|
||||
"name": "space",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "bigint",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "varchar(255)",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"invite_code": {
|
||||
"name": "invite_code",
|
||||
"type": "varchar(30)",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"owner_id": {
|
||||
"name": "owner_id",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"create_time": {
|
||||
"name": "create_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"update_time": {
|
||||
"name": "update_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"space_owner_id_user_id_fk": {
|
||||
"name": "space_owner_id_user_id_fk",
|
||||
"tableFrom": "space",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"owner_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.space_member": {
|
||||
"name": "space_member",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "bigint",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"space_id": {
|
||||
"name": "space_id",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"role": {
|
||||
"name": "role",
|
||||
"type": "smallint",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 2
|
||||
},
|
||||
"join_time": {
|
||||
"name": "join_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"update_time": {
|
||||
"name": "update_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"space_member_space_id_space_id_fk": {
|
||||
"name": "space_member_space_id_space_id_fk",
|
||||
"tableFrom": "space_member",
|
||||
"tableTo": "space",
|
||||
"columnsFrom": [
|
||||
"space_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"space_member_user_id_user_id_fk": {
|
||||
"name": "space_member_user_id_user_id_fk",
|
||||
"tableFrom": "space_member",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.user": {
|
||||
"name": "user",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "bigint",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"nickname": {
|
||||
"name": "nickname",
|
||||
"type": "varchar(255)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"avatar": {
|
||||
"name": "avatar",
|
||||
"type": "varchar(255)",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"status": {
|
||||
"name": "status",
|
||||
"type": "smallint",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 0
|
||||
},
|
||||
"last_login_time": {
|
||||
"name": "last_login_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"create_time": {
|
||||
"name": "create_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"update_time": {
|
||||
"name": "update_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.user_oauth": {
|
||||
"name": "user_oauth",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "bigint",
|
||||
"primaryKey": true,
|
||||
"notNull": true
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "bigint",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"type": {
|
||||
"name": "type",
|
||||
"type": "smallint",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 0
|
||||
},
|
||||
"openid": {
|
||||
"name": "openid",
|
||||
"type": "varchar(255)",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"create_time": {
|
||||
"name": "create_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"update_time": {
|
||||
"name": "update_time",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"user_oauth_user_id_user_id_fk": {
|
||||
"name": "user_oauth_user_id_user_id_fk",
|
||||
"tableFrom": "user_oauth",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
}
|
||||
},
|
||||
"enums": {},
|
||||
"schemas": {},
|
||||
"sequences": {},
|
||||
"roles": {},
|
||||
"policies": {},
|
||||
"views": {},
|
||||
"_meta": {
|
||||
"columns": {},
|
||||
"schemas": {},
|
||||
"tables": {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": "7",
|
||||
"dialect": "postgresql",
|
||||
"entries": [
|
||||
{
|
||||
"idx": 0,
|
||||
"version": "7",
|
||||
"when": 1771934733209,
|
||||
"tag": "0000_omniscient_nightcrawler",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// @ts-check
|
||||
import eslint from '@eslint/js';
|
||||
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
||||
import globals from 'globals';
|
||||
import tseslint from 'typescript-eslint';
|
||||
|
||||
export default tseslint.config(
|
||||
{
|
||||
ignores: ['eslint.config.mjs'],
|
||||
},
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommendedTypeChecked,
|
||||
eslintPluginPrettierRecommended,
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node,
|
||||
...globals.jest,
|
||||
},
|
||||
sourceType: 'commonjs',
|
||||
parserOptions: {
|
||||
projectService: true,
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
rules: {
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-floating-promises': 'warn',
|
||||
'@typescript-eslint/no-unsafe-argument': 'warn',
|
||||
"prettier/prettier": ["error", { endOfLine: "auto" }],
|
||||
},
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/nest-cli",
|
||||
"collection": "@nestjs/schematics",
|
||||
"sourceRoot": "src",
|
||||
"compilerOptions": {
|
||||
"deleteOutDir": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"name": "allapp-nest",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"private": true,
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
"build": "nest build",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "cross-env NODE_ENV=dev nest start",
|
||||
"start:dev": "cross-env NODE_ENV=dev nest start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
"start:prod": "cross-env NODE_ENV=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": "jest --config ./test/jest-e2e.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^11.0.1",
|
||||
"@nestjs/config": "^4.0.3",
|
||||
"@nestjs/core": "^11.0.1",
|
||||
"@nestjs/platform-express": "^11.0.1",
|
||||
"@nestjs/platform-fastify": "^11.1.14",
|
||||
"cross-env": "^10.1.0",
|
||||
"drizzle-orm": "^0.45.1",
|
||||
"js-yaml": "^4.1.1",
|
||||
"nest-winston": "^1.10.2",
|
||||
"pg": "^8.18.0",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rxjs": "^7.8.1",
|
||||
"winston": "^3.19.0",
|
||||
"winston-daily-rotate-file": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/eslintrc": "^3.2.0",
|
||||
"@eslint/js": "^9.18.0",
|
||||
"@nestjs/cli": "^11.0.0",
|
||||
"@nestjs/schematics": "^11.0.0",
|
||||
"@nestjs/testing": "^11.0.1",
|
||||
"@types/express": "^5.0.0",
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/node": "^22.10.7",
|
||||
"@types/pg": "^8.16.0",
|
||||
"@types/supertest": "^6.0.2",
|
||||
"drizzle-kit": "^0.31.9",
|
||||
"eslint": "^9.18.0",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
"eslint-plugin-prettier": "^5.2.2",
|
||||
"globals": "^16.0.0",
|
||||
"jest": "^30.0.0",
|
||||
"prettier": "^3.4.2",
|
||||
"source-map-support": "^0.5.21",
|
||||
"supertest": "^7.0.0",
|
||||
"ts-jest": "^29.2.5",
|
||||
"ts-loader": "^9.5.2",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsconfig-paths": "^4.2.0",
|
||||
"typescript": "^5.7.3",
|
||||
"typescript-eslint": "^8.20.0"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"json",
|
||||
"ts"
|
||||
],
|
||||
"rootDir": "src",
|
||||
"testRegex": ".*\\.spec\\.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
},
|
||||
"collectCoverageFrom": [
|
||||
"**/*.(t|j)s"
|
||||
],
|
||||
"coverageDirectory": "../coverage",
|
||||
"testEnvironment": "node"
|
||||
}
|
||||
}
|
||||
Generated
+7625
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,10 @@
|
||||
server:
|
||||
port: 8080
|
||||
db:
|
||||
host: 117.72.182.135
|
||||
port: 5432
|
||||
user: postgres
|
||||
password: zhang520..
|
||||
dbname: base
|
||||
timezone: Asia/Shanghai
|
||||
sll_mode: false
|
||||
Whitespace-only changes.
@@ -0,0 +1,22 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
|
||||
describe('AppController', () => {
|
||||
let appController: AppController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
}).compile();
|
||||
|
||||
appController = app.get<AppController>(AppController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(appController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { AppService } from './app.service';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
constructor(private readonly appService: AppService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.appService.getHello();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { configuration } from './config';
|
||||
import { AuthModule } from './modules/auth/auth.module';
|
||||
import { UserModule } from './modules/user/user.module';
|
||||
import { GlobalWinstonModule } from './common/global.winston.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
load: [configuration],
|
||||
}),
|
||||
GlobalWinstonModule.forRoot(),
|
||||
AuthModule,
|
||||
UserModule,
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
@Inject(ConfigService)
|
||||
private configService: ConfigService;
|
||||
|
||||
getHello(): string {
|
||||
console.log(this.configService.get('server.port'));
|
||||
|
||||
return 'Hello World!';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import { DynamicModule, Global, Module } from '@nestjs/common';
|
||||
import { WinstonModule, utilities } from 'nest-winston';
|
||||
import * as winston from 'winston';
|
||||
import 'winston-daily-rotate-file';
|
||||
|
||||
@Global()
|
||||
@Module({})
|
||||
export class GlobalWinstonModule {
|
||||
static forRoot(): DynamicModule {
|
||||
return {
|
||||
module: GlobalWinstonModule,
|
||||
imports: [
|
||||
// 其他 模块 LoginModule,
|
||||
WinstonModule.forRoot({
|
||||
transports: [
|
||||
new winston.transports.Console({
|
||||
level: 'info',
|
||||
format: winston.format.combine(
|
||||
winston.format.timestamp(),
|
||||
utilities.format.nestLike(),
|
||||
),
|
||||
}),
|
||||
new winston.transports.DailyRotateFile({
|
||||
level: 'error',
|
||||
dirname: 'logs',
|
||||
filename: 'error-%DATE%.log',
|
||||
datePattern: 'YYYY-MM-DD',
|
||||
zippedArchive: true, // 是否通过压缩的方式归档被轮换的日志文件。
|
||||
maxSize: '10m',
|
||||
maxFiles: '14d',
|
||||
format: winston.format.combine(
|
||||
winston.format.timestamp(),
|
||||
winston.format.json(),
|
||||
),
|
||||
}),
|
||||
new winston.transports.DailyRotateFile({
|
||||
level: 'info',
|
||||
dirname: 'logs',
|
||||
filename: 'info-%DATE%.log',
|
||||
datePattern: 'YYYY-MM-DD',
|
||||
zippedArchive: true, // 是否通过压缩的方式归档被轮换的日志文件。
|
||||
maxSize: '10m', // 设置日志文件的最大大小,m 表示 mb 。
|
||||
maxFiles: '14d', // 保留日志文件的最大天数,此处表示自动删除超过 14 天的日志文件。
|
||||
// 记录时添加时间戳信息
|
||||
format: winston.format.combine(
|
||||
winston.format.timestamp(),
|
||||
winston.format.json(),
|
||||
),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
controllers: [],
|
||||
providers: [],
|
||||
exports: [],
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Request } from '@nestjs/platform-fastify';
|
||||
|
||||
export const getReqMainInfo: (req: Request) => {
|
||||
[prop: string]: any;
|
||||
} = (req) => {
|
||||
// 获取 IP 第一种 不装 request-ip
|
||||
// const { query, headers, url, method, body, connection } = req;
|
||||
|
||||
// const xRealIp = headers["X-Real-IP"];
|
||||
// const xForwardedFor = headers["X-Forwarded-For"];
|
||||
// const { ip: cIp } = req;
|
||||
// const { remoteAddress } = connection || {};
|
||||
// const ip = xRealIp || xForwardedFor || cIp || remoteAddress;
|
||||
|
||||
// 获取 IP 第二种 安装 request-ip
|
||||
const { query, headers, url, method, body, connection, ip } = req;
|
||||
return {
|
||||
url,
|
||||
host: headers.host,
|
||||
headers,
|
||||
ip,
|
||||
method,
|
||||
query,
|
||||
body,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
import { loadConfig } from './loader';
|
||||
|
||||
export function configuration() {
|
||||
const config = loadConfig();
|
||||
|
||||
if (config.server.port < 1024 || config.server.port > 49151) {
|
||||
throw new Error('HTTP port must be between 1024 and 49151');
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import * as yaml from 'js-yaml';
|
||||
|
||||
import { AppConfig } from './types';
|
||||
|
||||
export function loadConfig(): AppConfig {
|
||||
const env = process.env.NODE_ENV || 'dev';
|
||||
const filePath = join(process.cwd(), 'resources', `config.${env}.yaml`);
|
||||
return yaml.load(readFileSync(filePath, 'utf8')) as AppConfig;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export interface AppConfig {
|
||||
server: { port: number };
|
||||
db: {
|
||||
host: string;
|
||||
port: number;
|
||||
user: string;
|
||||
password: string;
|
||||
dbname: string;
|
||||
ssl_mode?: boolean;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { drizzle } from 'drizzle-orm/node-postgres';
|
||||
import { Pool } from 'pg';
|
||||
import { loadConfig } from '@/config/loader';
|
||||
|
||||
const config = loadConfig();
|
||||
|
||||
// 创建连接池
|
||||
const pool = new Pool({
|
||||
host: config.db.host,
|
||||
port: config.db.port,
|
||||
user: config.db.user,
|
||||
password: config.db.password,
|
||||
database: config.db.dbname,
|
||||
ssl: config.db.ssl_mode ?? false,
|
||||
max: 10, // 最大连接数,默认 10
|
||||
idleTimeoutMillis: 30000, // 连接空闲多久后释放
|
||||
connectionTimeoutMillis: 2000, // 连接超时
|
||||
});
|
||||
|
||||
// 使用 drizzle 绑定 pool
|
||||
const db = drizzle(pool);
|
||||
|
||||
export { db };
|
||||
@@ -0,0 +1,14 @@
|
||||
import { pgTable } from 'drizzle-orm/pg-core';
|
||||
|
||||
export const financeCategoryDefault = pgTable(
|
||||
'finance_category_default',
|
||||
(t) => ({
|
||||
id: t.bigint({ mode: 'bigint' }).primaryKey(),
|
||||
name: t.varchar({ length: 64 }).notNull(),
|
||||
icon: t.varchar({ length: 64 }).notNull(),
|
||||
type: t.smallint().notNull().default(0),
|
||||
sort_number: t.integer().notNull().default(0),
|
||||
create_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
update_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
}),
|
||||
);
|
||||
@@ -0,0 +1,25 @@
|
||||
import { pgTable } from 'drizzle-orm/pg-core';
|
||||
import { user } from './user';
|
||||
import { space } from './space';
|
||||
|
||||
export const financeCategorySpace = pgTable('finance_category_space', (t) => ({
|
||||
id: t.bigint({ mode: 'bigint' }).primaryKey(),
|
||||
space_id: t
|
||||
.bigint({ mode: 'bigint' })
|
||||
.notNull()
|
||||
.references(() => space.id),
|
||||
name: t.varchar({ length: 64 }).notNull(),
|
||||
icon: t.varchar({ length: 64 }).notNull(),
|
||||
type: t.smallint().notNull().default(0),
|
||||
sort_number: t.integer().notNull().default(0),
|
||||
create_by: t
|
||||
.bigint({ mode: 'bigint' })
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
create_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
update_by: t
|
||||
.bigint({ mode: 'bigint' })
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
update_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
}));
|
||||
@@ -0,0 +1,28 @@
|
||||
import { pgTable } from 'drizzle-orm/pg-core';
|
||||
import { user } from './user';
|
||||
import { space } from './space';
|
||||
import { financeCategorySpace } from './finance_category_space';
|
||||
export const financeRecord = pgTable('finance_record', (t) => ({
|
||||
id: t.bigint({ mode: 'bigint' }).primaryKey(),
|
||||
category_id: t
|
||||
.bigint({ mode: 'bigint' })
|
||||
.notNull()
|
||||
.references(() => financeCategorySpace.id),
|
||||
space_id: t
|
||||
.bigint({ mode: 'bigint' })
|
||||
.notNull()
|
||||
.references(() => space.id),
|
||||
amount: t.numeric({ precision: 12, scale: 2, mode: 'number' }).notNull(),
|
||||
remark: t.varchar({ length: 255 }),
|
||||
record_time: t.date(),
|
||||
create_by: t
|
||||
.bigint({ mode: 'bigint' })
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
create_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
update_by: t
|
||||
.bigint({ mode: 'bigint' })
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
update_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
}));
|
||||
@@ -0,0 +1,17 @@
|
||||
import { pgTable } from 'drizzle-orm/pg-core';
|
||||
import { space } from './space';
|
||||
|
||||
export const session = pgTable('session', (t) => ({
|
||||
id: t.bigint({ mode: 'bigint' }).primaryKey(),
|
||||
space_id: t
|
||||
.bigint({ mode: 'bigint' })
|
||||
.notNull()
|
||||
.references(() => space.id),
|
||||
type: t.smallint().notNull().default(0),
|
||||
name: t.varchar({ length: 64 }),
|
||||
avatar: t.varchar({ length: 255 }),
|
||||
description: t.text(),
|
||||
status: t.smallint().notNull().default(0),
|
||||
create_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
update_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
}));
|
||||
@@ -0,0 +1,22 @@
|
||||
import { pgTable } from 'drizzle-orm/pg-core';
|
||||
import { user } from './user';
|
||||
import { session } from './session';
|
||||
import { sessionMessage } from './session_message';
|
||||
export const sessionMember = pgTable('session_member', (t) => ({
|
||||
id: t.bigint({ mode: 'bigint' }).primaryKey(),
|
||||
session_id: t
|
||||
.bigint({ mode: 'bigint' })
|
||||
.notNull()
|
||||
.references(() => session.id),
|
||||
user_id: t
|
||||
.bigint({ mode: 'bigint' })
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
remark: t.varchar({ length: 255 }),
|
||||
is_top: t.smallint().notNull().default(0),
|
||||
unread_count: t.integer().default(0),
|
||||
last_msg_id: t.bigint({ mode: 'bigint' }).references(() => sessionMessage.id),
|
||||
status: t.integer().default(0),
|
||||
create_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
update_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
}));
|
||||
@@ -0,0 +1,18 @@
|
||||
import { pgTable } from 'drizzle-orm/pg-core';
|
||||
import { user } from './user';
|
||||
import { session } from './session';
|
||||
|
||||
export const sessionMessage = pgTable('session_message', (t) => ({
|
||||
id: t.bigint({ mode: 'bigint' }).primaryKey(),
|
||||
session_id: t
|
||||
.bigint({ mode: 'bigint' })
|
||||
.notNull()
|
||||
.references(() => session.id),
|
||||
sender_id: t
|
||||
.bigint({ mode: 'bigint' })
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
content: t.text().notNull(),
|
||||
content_type: t.smallint().notNull().default(0),
|
||||
create_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
}));
|
||||
@@ -0,0 +1,14 @@
|
||||
import { pgTable } from 'drizzle-orm/pg-core';
|
||||
import { user } from './user';
|
||||
|
||||
export const space = pgTable('space', (t) => ({
|
||||
id: t.bigint({ mode: 'bigint' }).primaryKey(),
|
||||
name: t.varchar({ length: 255 }).notNull(),
|
||||
invite_code: t.varchar({ length: 30 }).notNull(),
|
||||
owner_id: t
|
||||
.bigint({ mode: 'bigint' })
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
create_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
update_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
}));
|
||||
@@ -0,0 +1,18 @@
|
||||
import { pgTable } from 'drizzle-orm/pg-core';
|
||||
import { user } from './user';
|
||||
import { space } from './space';
|
||||
|
||||
export const spaceMember = pgTable('space_member', (t) => ({
|
||||
id: t.bigint({ mode: 'bigint' }).primaryKey(),
|
||||
space_id: t
|
||||
.bigint({ mode: 'bigint' })
|
||||
.notNull()
|
||||
.references(() => space.id),
|
||||
user_id: t
|
||||
.bigint({ mode: 'bigint' })
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
role: t.smallint().notNull().default(2),
|
||||
join_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
update_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
}));
|
||||
@@ -0,0 +1,11 @@
|
||||
import { pgTable } from 'drizzle-orm/pg-core';
|
||||
|
||||
export const user = pgTable('user', (t) => ({
|
||||
id: t.bigint({ mode: 'bigint' }).primaryKey(),
|
||||
nickname: t.varchar({ length: 255 }),
|
||||
avatar: t.varchar({ length: 255 }),
|
||||
status: t.smallint().notNull().default(0),
|
||||
last_login_time: t.timestamp({ withTimezone: true }),
|
||||
create_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
update_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
}));
|
||||
@@ -0,0 +1,14 @@
|
||||
import { pgTable } from 'drizzle-orm/pg-core';
|
||||
import { user } from './user';
|
||||
|
||||
export const userOauth = pgTable('user_oauth', (t) => ({
|
||||
id: t.bigint({ mode: 'bigint' }).primaryKey(),
|
||||
user_id: t
|
||||
.bigint({ mode: 'bigint' })
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
type: t.smallint().notNull().default(0),
|
||||
openid: t.varchar({ length: 255 }).notNull(),
|
||||
create_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
update_time: t.timestamp({ withTimezone: true }).defaultNow(),
|
||||
}));
|
||||
@@ -0,0 +1,30 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import {
|
||||
FastifyAdapter,
|
||||
NestFastifyApplication,
|
||||
} from '@nestjs/platform-fastify';
|
||||
import { AppModule } from './app.module';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { db } from './db';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create<NestFastifyApplication>(
|
||||
AppModule,
|
||||
new FastifyAdapter({
|
||||
trustProxy: true,
|
||||
}),
|
||||
);
|
||||
|
||||
const configService = app.get(ConfigService);
|
||||
|
||||
await app.listen(configService.get<number>('server.port', 3000));
|
||||
|
||||
try {
|
||||
await db.execute('select 1');
|
||||
} catch (error) {
|
||||
console.error('数据库连接失败:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
bootstrap().catch(console.log);
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AuthController } from './auth.controller';
|
||||
|
||||
describe('AuthController', () => {
|
||||
let controller: AuthController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [AuthController],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<AuthController>(AuthController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
import { Controller } from '@nestjs/common';
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
@Controller('auth')
|
||||
export class AuthController {
|
||||
constructor(private readonly authService: AuthService) {}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AuthController } from './auth.controller';
|
||||
import { AuthService } from './auth.service';
|
||||
import { UserModule } from '../user/user.module';
|
||||
|
||||
@Module({
|
||||
imports: [UserModule],
|
||||
controllers: [AuthController],
|
||||
providers: [AuthService],
|
||||
})
|
||||
export class AuthModule {}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
describe('AuthService', () => {
|
||||
let service: AuthService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [AuthService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<AuthService>(AuthService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { UserService } from './user.service';
|
||||
|
||||
@Module({
|
||||
providers: [UserService],
|
||||
})
|
||||
export class UserModule {}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { UserService } from './user.service';
|
||||
|
||||
describe('UserService', () => {
|
||||
let service: UserService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [UserService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<UserService>(UserService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class UserService {}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import request from 'supertest';
|
||||
import { App } from 'supertest/types';
|
||||
import { AppModule } from './../src/app.module';
|
||||
|
||||
describe('AppController (e2e)', () => {
|
||||
let app: INestApplication<App>;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Hello World!');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "nodenext",
|
||||
"moduleResolution": "nodenext",
|
||||
"resolvePackageJsonExports": true,
|
||||
"esModuleInterop": true,
|
||||
"isolatedModules": true,
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "ES2023",
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"baseUrl": "./",
|
||||
"incremental": true,
|
||||
"skipLibCheck": true,
|
||||
"strictNullChecks": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noImplicitAny": false,
|
||||
"strictBindCallApply": false,
|
||||
"noFallthroughCasesInSwitch": false,
|
||||
"paths": {
|
||||
"@/*": ["src/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user