-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't get it working on Windows #815
Comments
What I've done to get this working so far:
const fs = require('fs');
const chalk = require('chalk');
const express = require('express');
const cors = require('cors');
const path = require('path');
const https = require('https');
const bodyParser = require('body-parser');
const router = require('./router');
const Db = require('./db');
const NotificationManager = require('./utils/notification');
const TLS_KEY_PATH = path.join(__dirname, '..', '..', 'private', 'key.pem');
const TLS_CERT_PATH = path.join(__dirname, '..', '..', 'private', 'cert.pem');
function startAndListen(app, port) {
return new Promise((resolve) => {
app.listen(port, () => {
resolve();
});
})
}
var corsOptions = {
credentials: true,
origin: function (origin, callback) {
callback(null, true);
}
}
let httpsOptions = {
key: fs.readFileSync(TLS_KEY_PATH),
cert: fs.readFileSync(TLS_CERT_PATH)
};
class ApiServer {
constructor() {
this.db = new Db();
this.notifications = null;
}
_startApi() {
this.app = express();
this.app.disable('x-powered-by');
this.app.use(bodyParser.json());
this.app.use(cors(corsOptions));
this.app.use('/api', router(this));
this.app.use('/images', express.static(path.join(__dirname, '..', 'images')));
this.app.use('/', express.static(path.join(__dirname, '..', '..', 'dist')));
return startAndListen(https.createServer(httpsOptions, this.app), 3100);
}
start() {
return this.db.start()
.then(() => {
this.notifications = new NotificationManager(this);
})
.then(() => this._startApi())
.then(() => {
process.stdout.write(chalk.magenta('💻 API has started on https://localhost:3100/api'));
});
}
}
let api = new ApiServer();
api.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there,
First of all I have to say that I am very excited to do this tutorial, but I got stuck in the first exercise =/
Turns out these guys were having the same issue I'm facing, but there was no answer for the issue
#47
After 3 hours trying to make it work I decided to open this thread.
So, I have all the packages and tools installed in my machine. By looking at that post above I figured I needed OpenSSL installed, and also Git Bash to run the commands (why??).
npm run watch:api
seems to be workinghowever,
npm run watch
returns me thisAny idea what be causing it? Again, this is the same error someones described in that other post, but there was no answer explaining how to solve it.
Would it be possible to have a tutorial showing how to set up the environment on windows?
Also... why using NPM and Yarn? Should we not be using only one of them?
The text was updated successfully, but these errors were encountered: