Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions adminforth/commands/createApp/templates/api.ts.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Express } from "express";
import { IAdminForth } from "adminforth";

export function initApi(app: Express, admin: IAdminForth) {
app.get(`${admin.config.baseUrl}/api/hello/`,
(req, res) => {
res.json({ message: "Hello from AdminForth API!" });
}
);
}
5 changes: 4 additions & 1 deletion adminforth/commands/createApp/templates/index.ts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import usersResource from "./resources/adminuser.js";
import { fileURLToPath } from 'url';
import path from 'path';
import { Filters } from 'adminforth';

import { initApi } from './api.js';

const ADMIN_BASE_URL = '';

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

initApi(app, admin);

const port = 3500;

admin.bundleNow({ hotReload: process.env.NODE_ENV === 'development' }).then(() => {
Expand Down
5 changes: 5 additions & 0 deletions adminforth/commands/createApp/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ async function writeTemplateFiles(dirname, cwd, options) {
dest: 'index.ts',
data: { appName },
},
{
src: 'api.ts.hbs',
dest: 'api.ts',
data: {},
},
{
src: '.gitignore.hbs',
dest: '.gitignore',
Expand Down