feat: add code manager
This commit is contained in:
parent
60653a5ba8
commit
c92f42933e
@ -10,13 +10,13 @@ fs.writeFileSync(
|
||||
{
|
||||
name: 'codeflow',
|
||||
version: '1.0.0',
|
||||
dependencies: {
|
||||
devDependencies: {
|
||||
'@babel/core': '^7.24.7',
|
||||
'@babel/preset-env': '^7.24.7',
|
||||
'@babel/preset-typescript': '^7.24.7',
|
||||
sequelize: '^6.37.3',
|
||||
'socket.io': '^4.7.5',
|
||||
pg: '^8.12.0'
|
||||
pg: '^8.12.0',
|
||||
},
|
||||
},
|
||||
null,
|
||||
|
@ -150,3 +150,19 @@ managerList.run = async (ctx) => {
|
||||
return ctx;
|
||||
};
|
||||
router.add(managerList);
|
||||
|
||||
// get manager one
|
||||
export const managerOne = new Route('admin', 'getManagerOne');
|
||||
managerOne.run = async (ctx) => {
|
||||
const { id } = ctx.query;
|
||||
const code = manager.list.find((c) => c.id === id);
|
||||
if (code) {
|
||||
ctx.body = code;
|
||||
} else {
|
||||
ctx.body = 'not found';
|
||||
ctx.code = 404;
|
||||
}
|
||||
|
||||
return ctx;
|
||||
};
|
||||
router.add(managerOne);
|
||||
|
10
src/lib/dynamic-import.ts
Normal file
10
src/lib/dynamic-import.ts
Normal file
@ -0,0 +1,10 @@
|
||||
export const defaultImportModules = [
|
||||
{
|
||||
name: 'sequelize',
|
||||
version: '^6.6.5',
|
||||
},
|
||||
{
|
||||
name: 'pg',
|
||||
version: '^8.12.1',
|
||||
},
|
||||
];
|
@ -12,6 +12,7 @@ export type RouterCode = {
|
||||
type: RouterCodeType;
|
||||
middleware: string[];
|
||||
next: string;
|
||||
data: any;
|
||||
};
|
||||
|
||||
export enum RouterCodeType {
|
||||
@ -30,6 +31,7 @@ export class RouterCodeModel extends Model {
|
||||
declare type: RouterCodeType;
|
||||
declare middleware: string[];
|
||||
declare next: string; // 如果是中间件,不存在
|
||||
declare data: any;
|
||||
}
|
||||
RouterCodeModel.init(
|
||||
{
|
||||
@ -75,6 +77,10 @@ RouterCodeModel.init(
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: '',
|
||||
},
|
||||
data: {
|
||||
type: DataTypes.JSON,
|
||||
defaultValue: {},
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
|
Loading…
x
Reference in New Issue
Block a user