Add PM2 deployment support

This commit is contained in:
lofyer
2026-08-24 17:59:49 +08:00
parent 5ff80caf7e
commit 63bbbac922
16 changed files with 450 additions and 55 deletions
+30
View File
@@ -20,6 +20,36 @@ afterEach(async () => {
})
describe('AuthService', () => {
it('creates the initial administrator only when the database is empty', async () => {
const directory = await mkdtemp(join(tmpdir(), 'product-issue-auth-'))
directories.push(directory)
const database = openDatabase(join(directory, 'database.sqlite'))
databases.push(database)
const auth = new AuthService(database, 'secret', 60 * 60 * 1_000)
await expect(
auth.createInitialAdmin({
email: 'first@example.com',
displayName: 'First admin',
password: 'first secure password'
})
).resolves.toBe(true)
await expect(
auth.createInitialAdmin({
email: 'second@example.com',
displayName: 'Second admin',
password: 'second secure password'
})
).resolves.toBe(false)
await expect(
auth.login('first@example.com', 'first secure password')
).resolves.toMatchObject({ displayName: 'First admin' })
await expect(
auth.login('second@example.com', 'second secure password')
).resolves.toBeUndefined()
})
it('invalidates existing sessions when an administrator is reset', async () => {
const directory = await mkdtemp(join(tmpdir(), 'product-issue-auth-'))
directories.push(directory)