-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4cec6e
commit ea1ff83
Showing
6 changed files
with
57 additions
and
12 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
// Start Express web app based on Express | ||
const web = require('./src/web'); | ||
return new web(); | ||
|
||
// CONFIG | ||
const PublicConfig = require('../config/projects'); | ||
var localConfig = new PublicConfig(); | ||
|
||
const web = require('./server/web'); | ||
return new web('PROMAGEN ONE ', 'localhost', localConfig.port, '../public'); | ||
|
||
// const web = require('./server/express'); | ||
// return new web('PROMAGEN ONE ', 'localhost', localConfig.port, '../public'); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module.exports = function (application, domain = 'localhost', port = 3000, public_src = "./") { | ||
|
||
const express = require('express'); | ||
|
||
const app = express(); | ||
port = process.env.PORT || port; | ||
|
||
// NEW - Add CORS headers - see https://enable-cors.org/server_expressjs.html | ||
app.use(function (req, res, next) { | ||
res.header("Access-Control-Allow-Origin", "*"); | ||
res.header( | ||
"Access-Control-Allow-Headers", | ||
"Origin, X-Requested-With, Content-Type, Accept" | ||
); | ||
next(); | ||
}); | ||
|
||
app.use(express.static(public_src)); | ||
|
||
// API endpoint | ||
app.get("/api/ping", (req, res) => { | ||
res.send({ | ||
msg: "Hello, World" | ||
}); | ||
}); | ||
|
||
|
||
// app.get('/', (req, res) => { | ||
// res.send('An alligator approaches!'); | ||
// }); | ||
|
||
// app.listen(PORT, () => console.log(`listening on ${PORT}`)); | ||
var url = 'http://' + domain + ':' + port; | ||
app.listen(port, () => console.log(application + ' is listening on: ' + url)); | ||
|
||
return app; | ||
}; |
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
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
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