Skip to content

Commit 3c27642

Browse files
committed
Merge branch 'next' of github.com:devforth/adminforth into next
2 parents 10b4ba2 + 949ad02 commit 3c27642

35 files changed

+648
-101
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Express } from "express";
2+
import { IAdminForth } from "adminforth";
3+
4+
export function initApi(app: Express, admin: IAdminForth) {
5+
app.get(`${admin.config.baseUrl}/api/hello/`,
6+
(req, res) => {
7+
res.json({ message: "Hello from AdminForth API!" });
8+
}
9+
);
10+
}

adminforth/commands/createApp/templates/index.ts.hbs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import usersResource from "./resources/adminuser.js";
44
import { fileURLToPath } from 'url';
55
import path from 'path';
66
import { Filters } from 'adminforth';
7-
7+
import { initApi } from './api.js';
8+
89
const ADMIN_BASE_URL = '';
910

1011
export const admin = new AdminForth({
@@ -69,6 +70,8 @@ if (fileURLToPath(import.meta.url) === path.resolve(process.argv[1])) {
6970
const app = express();
7071
app.use(express.json());
7172

73+
initApi(app, admin);
74+
7275
const port = 3500;
7376

7477
admin.bundleNow({ hotReload: process.env.NODE_ENV === 'development' }).then(() => {

adminforth/commands/createApp/utils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ async function writeTemplateFiles(dirname, cwd, options) {
235235
dest: 'index.ts',
236236
data: { appName },
237237
},
238+
{
239+
src: 'api.ts.hbs',
240+
dest: 'api.ts',
241+
data: {},
242+
},
238243
{
239244
src: '.gitignore.hbs',
240245
dest: '.gitignore',
135 KB
Loading
157 KB
Loading
71 KB
Loading
70.2 KB
Loading
71 KB
Loading
305 KB
Loading
300 KB
Loading

0 commit comments

Comments
 (0)