在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:t3chnoboy/koa-mongo-rest开源软件地址:https://github.com/t3chnoboy/koa-mongo-rest开源编程语言:JavaScript 46.6%开源软件介绍:Koa mongo RESTEasy REST api for koa server InstallationInstall using npm: npm install koa-mongo-rest UsageRequire library generateApi = require('koa-mongo-rest'); Create mongoose model mongoUrl = '127.0.0.1:27017';
mongoose = require('mongoose');
mongoose.connect(mongoUrl);
schema = new mongoose.Schema({
email: String,
name: String,
password: String,
address: String,
zipcode: Number,
lists: Array
});
model = mongoose.model('users', schema); Create server var koa = require('koa');
var router = require('koa-router');
var app = koa();
//router is required
app.use(router(app));
//add REST routes to your app. Prefix is optional
generateApi(app, model, '/api');
app.listen(process.env.PORT || 5000); Following REST API is now created for you:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论