Skip to content

Commit b308e80

Browse files
committed
Add express test
1 parent 8152bbe commit b308e80

File tree

37 files changed

+1646
-87
lines changed

37 files changed

+1646
-87
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ devup_model
88
*.db
99
test-*-revisions
1010
__tests__/**/*.db
11+
tsconfig.tsbuildinfo

Cargo.lock

Lines changed: 50 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

__tests__/api/index.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ describe('api', () => {
33
const res = await fetch('http://localhost:8000/')
44
const data = await res.json()
55
expect(data).toEqual({
6-
message: 'Hello World',
6+
title: expect.stringContaining('project'),
7+
description: expect.stringContaining('project'),
78
})
89
})
910

__tests__/sql/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ describe.sequential('sqlite', async () => {
9999
const revisionSql = await pool.getRevisionSql(nextRevision, true)
100100
expect(revisionSql).toEqual([
101101
{
102-
sql: `CREATE TABLE user (id INTEGER NOT NULL, username VARCHAR(255) NOT NULL DEFAULT \`devup\`, tag TEXT NULL, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id))`,
102+
sql: `CREATE TABLE user (id INTEGER NOT NULL,username VARCHAR(255) NOT NULL DEFAULT \`devup\`,tag TEXT NULL,created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,PRIMARY KEY (id))`,
103103
params: [],
104104
},
105105
])

__tests__/sql/migrate.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe.sequential('sqlite', async () => {
6969
const revisionSql = await pool.getRevisionSql(nextRevision, true)
7070
expect(revisionSql).toEqual([
7171
{
72-
sql: `CREATE TABLE user (id INTEGER NOT NULL, username VARCHAR(255) NOT NULL DEFAULT \`devup\`, tag TEXT NULL, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id))`,
72+
sql: `CREATE TABLE user (id INTEGER NOT NULL,username VARCHAR(255) NOT NULL DEFAULT \`devup\`,tag TEXT NULL,created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,PRIMARY KEY (id))`,
7373
params: [],
7474
},
7575
])
@@ -108,7 +108,7 @@ describe.sequential('sqlite', async () => {
108108
const revisionSql = await pool.getRevisionSql(nextRevision, true)
109109
expect(revisionSql).toEqual([
110110
{
111-
sql: `CREATE TABLE setting (id INTEGER NOT NULL, description TEXT NOT NULL, PRIMARY KEY (id))`,
111+
sql: `CREATE TABLE setting (id INTEGER NOT NULL,description TEXT NOT NULL,PRIMARY KEY (id))`,
112112
params: [],
113113
},
114114
])

apps/sql-demo/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { createPostgresPool } from '@devup-sql/postgres'
1+
import { createPostgresConnection } from '@devup-sql/postgres'
22

33
async function main(): Promise<void> {
44
try {
55
console.log('[JS] create pool')
6-
const pool = await createPostgresPool()
6+
const pool = await createPostgresConnection({
7+
url: 'postgresql://postgres:postgres@localhost:5432/postgres',
8+
})
79

810
console.log('[JS] execute', pool)
911

libs/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Function
2+
- init_devup_api(initDevupApi) - initial
3+
4+
# Router
5+
- CrudRouter
6+
- SingletonRouter
7+
- AuthRouter
8+
- ProxyRouter
9+
- CustomRouter

libs/node/express/package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@devup-api/express",
3+
"version": "0.0.1",
4+
"main": "dist/index.js",
5+
"types": "dist/index.d.ts",
6+
"scripts": {
7+
"build": "tsc && vite build",
8+
"test": "vitest --run"
9+
},
10+
"dependencies": {
11+
"@devup-api/model": "workspace:*",
12+
"@devup-api/router": "workspace:*"
13+
},
14+
"devDependencies": {
15+
"@types/express": "^5.0",
16+
"vite": "^6.3.5",
17+
"vite-plugin-dts": "^4.5.4"
18+
}
19+
}

libs/node/express/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './init'

libs/node/express/src/init.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { importModels } from '@devup-api/model'
2+
import { importRoutes } from '@devup-api/router'
3+
import type { Express } from 'express'
4+
5+
function initDevupApi(app: Express) {
6+
globalThis.require = require
7+
importModels()
8+
importRoutes()
9+
app.get('/', (_, res) => {
10+
res.json({
11+
title: 'express project',
12+
description: 'express project',
13+
})
14+
})
15+
}
16+
17+
export { initDevupApi }

0 commit comments

Comments
 (0)