mirror of
https://github.com/diced/zipline.git
synced 2026-01-08 11:21:47 -08:00
feat: version api
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
"sideEffects": false,
|
||||
"version": "4.0.0-dev.1",
|
||||
"version": "4.0.0-dev+1",
|
||||
"scripts": {
|
||||
"build": "run-p \"build:*\"",
|
||||
"build:next": "next build",
|
||||
|
||||
@@ -18,6 +18,7 @@ import { ApiUserUrlsResponse } from '@/pages/api/user/urls';
|
||||
import { ApiUserUrlsIdResponse } from '@/pages/api/user/urls/[id]';
|
||||
import { ApiUsersResponse } from '@/pages/api/users';
|
||||
import { ApiUsersIdResponse } from '@/pages/api/users/[id]';
|
||||
import { ApiVersionResponse } from '@/pages/api/version';
|
||||
|
||||
export type Response = {
|
||||
'/api/auth/oauth': ApiAuthOauthResponse;
|
||||
@@ -40,4 +41,5 @@ export type Response = {
|
||||
'/api/healthcheck': ApiHealthcheckResponse;
|
||||
'/api/setup': ApiSetupResponse;
|
||||
'/api/upload': ApiUploadResponse;
|
||||
'/api/version': ApiVersionResponse;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createToken, hashPassword } from '@/lib/crypto';
|
||||
import { prisma } from '@/lib/db';
|
||||
import { User } from '@/lib/db/models/user';
|
||||
import { User, userSelect } from '@/lib/db/models/user';
|
||||
import { getZipline } from '@/lib/db/models/zipline';
|
||||
import { log } from '@/lib/logger';
|
||||
import { combine } from '@/lib/middleware/combine';
|
||||
@@ -40,13 +40,7 @@ export async function handler(req: NextApiReq<Body>, res: NextApiRes<ApiSetupRes
|
||||
role: 'SUPERADMIN',
|
||||
token: createToken(),
|
||||
},
|
||||
select: {
|
||||
role: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
username: true,
|
||||
},
|
||||
select: userSelect,
|
||||
});
|
||||
|
||||
logger.info('first setup complete');
|
||||
|
||||
15
src/pages/api/version.ts
Normal file
15
src/pages/api/version.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { combine } from '@/lib/middleware/combine';
|
||||
import { method } from '@/lib/middleware/method';
|
||||
import { ziplineAuth } from '@/lib/middleware/ziplineAuth';
|
||||
import { NextApiReq, NextApiRes } from '@/lib/response';
|
||||
import packageJson from '../../../package.json';
|
||||
|
||||
export type ApiVersionResponse = {
|
||||
version: string;
|
||||
};
|
||||
|
||||
export async function handler(_: NextApiReq, res: NextApiRes<ApiVersionResponse>) {
|
||||
return res.ok({ version: packageJson.version });
|
||||
}
|
||||
|
||||
export default combine([method(['GET']), ziplineAuth({ administratorOnly: true })], handler);
|
||||
Reference in New Issue
Block a user