1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| const express = require('express'); const ParseServer = require('parse-server').ParseServer; const ParseDashboard = require('parse-dashboard'); const appId = '1000' const masterKey = '2000'
const api = new ParseServer({ databaseURI: 'mongodb://localhost:27017/dev', // 连接MongoDB database appId: appId, masterKey: masterKey, // Keep this key secret! fileKey: 'optionalFileKey', serverURL: 'http://localhost:4040/parse' // change to https if needed });
const options = { allowInsecureHTTP: true }; // 若是强制启用https,这里可以改为false
const dashboard = new ParseDashboard({ apps: [ { serverURL: 'http://localhost:4040/parse', // 上线后改为远端地址,例如:http://yhorz.cn/parse appId: appId, masterKey: masterKey, appName: 'app' } ], users: [ { user:'cs', pass:'******', apps: [{appId: appId}] }, { user:'yh', pass:'******', apps: [{appId: appId}] } ], trustProxy: 1 }, options);
const app = express();
// make the Parse Server available at /parse app.use('/parse', api);
// make the Parse Dashboard available at /dashboard app.use('/dashboard', dashboard);
const httpServer = require('http').createServer(app); httpServer.listen(4040);
|