ChestnutJS
Headless CMS with Angular 6 Admin UI and GraphQL, Typegoose backend
Install / Use
/learn @Lambda-IT/ChestnutJSREADME
chestnutJS
Headless CMS with Angular 6.1 Admin UI and GraphQL, mongoose (typegoose) backend
Installation and usage
Using npm:
npm install --save chestnutjs
After installing chestnutJS the following function can be used to bootup the entire chestnut ecosystem: initChestnut. The configuration parameter is declared as:
export declare type ChestnutOptions = {
port: number;
models: {
// The models that chestnutJS should be able to handle
[name: string]: any;
};
mongoDb: string; // The mongoDb connection string
modelName?: {
// Optional parameters how the model names should be handled, if nothing is given the
// collection names of the mongoDB will and need to exactly match the models names
prefix?: string; // If the modelnames should be prefixed as DB collection name
pluralize?: true; // If the modelnames should be pluralized as DB collection name
kebabCase?: true; // If the modelnames should get kebabcased as DB collection name
};
publicFolder?: string;
sessionSecret: string;
apiUrl: string;
};
// Example
import * as cModels from './models';
// It is also possible to only expose some of the models
// import * as cModels from './models/Person';
const PORT = parseInt(process.env.PORT || '9000', 10);
initChestnut(
{
port: PORT,
models: cModels,
apiUrl: `http://localhost:${PORT}`,
sessionSecret: 'supersecret1234',
mongoDb: 'mongodb://localhost:27017/example-app',
},
initExampleApp
);
Where the second parameter (initExampleApp in the example) is an optional callback which gets the chestnutJS environment as parameter and needs to return a promise.
This can be used to configure the custom API endpoints or replace an already existing nodeJS mongoDB environment.
export declare type Chestnut = {
expressApp: express.Express;
store: Store;
logger: Log;
server: Server;
};
// Example
export async function initExampleApp(chestnut: Chestnut): Promise<void> {
try {
const { expressApp: app, server } = chestnut;
const connection = await mongoose.createConnection(URL, {
useMongoClient: true,
});
createModels(connection);
app.use('/api', customApiRoutes);
// Additional server features like websockets can be attached via the server object
// ...
} catch (e) {
console.error('Error', e);
chestnut.logger.error(e);
}
}
Related Skills
node-connect
347.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
