Created
August 3, 2018 21:08
-
-
Save gwenaelp/c37c1d711dac4b7299e87e59239aab1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const schemas = [{ | |
name: 'user', | |
apiType: 'CRUD', | |
apiEndPoint: 'user', | |
apiGetKey: 'name', | |
fields: [/* ... */], | |
}]; | |
const app = express(); | |
for (let i = 0; i < schemas.length; i++) { | |
const currentSchema = schemas[i]; | |
if(currentSchema.apiType === 'CRUD') { | |
app.get(`/${currentSchema.apiEndPoint}`, (req, res) => {}); | |
app.delete(`/${currentSchema.apiEndPoint}/:${currentSchema.apiGetKey}`, (req, res) => { | |
/* ... */ | |
}); | |
app.post(`/${currentSchema.apiEndPoint}/:${currentSchema.apiGetKey}`, (req, res) => { | |
/* ... */ | |
}); | |
app.put(`/${currentSchema.apiEndPoint}/:${currentSchema.apiGetKey}`, (req, res) => { | |
/* ... */ | |
}); | |
} | |
} | |
app.listen('9000', () => console.log(`Server listening on port 9000!`)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment