🚀 server dist typescript bundle
This commit is contained in:
parent
658d25b43f
commit
1b1d5c791b
16
dist/DbModels/CourseDbModel.js
vendored
Normal file
16
dist/DbModels/CourseDbModel.js
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var mongoose = require("mongoose");
|
||||
var CourseSchema = new mongoose.Schema({
|
||||
name: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
repo: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
});
|
||||
var CourseDbModel = mongoose.model('Course', CourseSchema);
|
||||
exports.default = CourseDbModel;
|
||||
//# sourceMappingURL=CourseDbModel.js.map
|
||||
1
dist/DbModels/CourseDbModel.js.map
vendored
Normal file
1
dist/DbModels/CourseDbModel.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CourseDbModel.js","sourceRoot":"","sources":["../../src/DbModels/CourseDbModel.ts"],"names":[],"mappings":";;AAAA,mCAAoC;AAEpC,IAAM,YAAY,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACf;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACf;CACF,CAAC,CAAA;AAEF,IAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;AAE5D,kBAAe,aAAa,CAAA"}
|
||||
20
dist/DbModels/CourseRequestDbModel.js
vendored
Normal file
20
dist/DbModels/CourseRequestDbModel.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var mongoose = require("mongoose");
|
||||
var CourseRequestSchema = new mongoose.Schema({
|
||||
contactName: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
email: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
githubRepo: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
});
|
||||
var CourseRequestDbModel = mongoose.model('RequestCourse', CourseRequestSchema);
|
||||
exports.default = CourseRequestDbModel;
|
||||
//# sourceMappingURL=CourseRequestDbModel.js.map
|
||||
1
dist/DbModels/CourseRequestDbModel.js.map
vendored
Normal file
1
dist/DbModels/CourseRequestDbModel.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CourseRequestDbModel.js","sourceRoot":"","sources":["../../src/DbModels/CourseRequestDbModel.ts"],"names":[],"mappings":";;AAAA,mCAAoC;AAEpC,IAAM,mBAAmB,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC;IAC9C,WAAW,EAAE;QACX,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACf;IACD,KAAK,EAAE;QACL,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACf;IACD,UAAU,EAAE;QACV,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACf;CACF,CAAC,CAAA;AAEF,IAAM,oBAAoB,GAAG,QAAQ,CAAC,KAAK,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAA;AAEjF,kBAAe,oBAAoB,CAAA"}
|
||||
95
dist/Routes/apiRoute.js
vendored
Normal file
95
dist/Routes/apiRoute.js
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var express = require("express");
|
||||
var CourseDbModel_1 = require("../DbModels/CourseDbModel");
|
||||
var CourseRequestDbModel_1 = require("../DbModels/CourseRequestDbModel");
|
||||
var router = express.Router();
|
||||
router.get('/courses', function (request, response) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var courses, err_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
return [4 /*yield*/, CourseDbModel_1.default.find()];
|
||||
case 1:
|
||||
courses = _a.sent();
|
||||
response.send(courses);
|
||||
return [2 /*return*/];
|
||||
case 2:
|
||||
err_1 = _a.sent();
|
||||
console.log(err_1);
|
||||
response.send('Error finding');
|
||||
return [2 /*return*/];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); });
|
||||
router.post('/requestCourse', function (request, response) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var _a, contactName, email, githubRepo, responseToClient, createDocuimentResponse, err_2;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
_a = request.body, contactName = _a.contactName, email = _a.email, githubRepo = _a.githubRepo;
|
||||
responseToClient = {
|
||||
status: 'ERR',
|
||||
messages: ['Could not save Add Course Request']
|
||||
};
|
||||
_b.label = 1;
|
||||
case 1:
|
||||
_b.trys.push([1, 3, , 4]);
|
||||
return [4 /*yield*/, CourseRequestDbModel_1.default.create({ contactName: contactName, email: email, githubRepo: githubRepo })];
|
||||
case 2:
|
||||
createDocuimentResponse = _b.sent();
|
||||
if (createDocuimentResponse._id) {
|
||||
responseToClient.status = 'OK';
|
||||
responseToClient.messages = ['Add Courese Requested'];
|
||||
}
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
err_2 = _b.sent();
|
||||
console.log(err_2);
|
||||
return [3 /*break*/, 4];
|
||||
case 4:
|
||||
response.send(responseToClient);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); });
|
||||
exports.default = router;
|
||||
//# sourceMappingURL=apiRoute.js.map
|
||||
1
dist/Routes/apiRoute.js.map
vendored
Normal file
1
dist/Routes/apiRoute.js.map
vendored
Normal file
@ -0,0 +1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AC,IAAI,CAAC,gBAAgB,CAAC,CAAA;;;;KAChC,CAAC,CAAA;AAEF,kBAAe,MAAM,CAAA"}
|
||||
46
dist/Server/Server.js
vendored
Normal file
46
dist/Server/Server.js
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var express = require("express");
|
||||
var mongoose = require("mongoose");
|
||||
var path = require("path");
|
||||
var body_parser_1 = require("body-parser");
|
||||
var apiRoute_1 = require("../Routes/apiRoute.js");
|
||||
var Server = /** @class */ (function () {
|
||||
function Server() {
|
||||
this.createApp();
|
||||
this.createRoutes();
|
||||
this.setOptions();
|
||||
}
|
||||
Server.prototype.createApp = function () {
|
||||
this.app = express();
|
||||
this.app.use(body_parser_1.json());
|
||||
this.app.use(express.static(path.join(process.cwd(), '/web/build')));
|
||||
this.connectToDatabase();
|
||||
};
|
||||
Server.prototype.createRoutes = function () {
|
||||
this.app.use('/api', apiRoute_1.default);
|
||||
this.app.use('/', function (request, response, next) {
|
||||
response.sendFile(path.join(process.cwd(), './web/build/index.html'));
|
||||
});
|
||||
};
|
||||
Server.prototype.connectToDatabase = function () {
|
||||
mongoose.connect(process.env.DBCONNECTION, {
|
||||
useCreateIndex: true,
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true
|
||||
}, function () {
|
||||
console.log('Connected to Database');
|
||||
});
|
||||
};
|
||||
Server.prototype.setOptions = function () {
|
||||
this.app.use(function (request, response, next) {
|
||||
response.header('Access-Control-Allow-Origin', request.headers.origin || '*');
|
||||
response.header('Access-Control-Allow-Methods', 'GET,POST,PUT,PATCH,HEAD,DELETE,OPTIONS');
|
||||
response.header('Access-Control-Allow-Headers', 'Content-Type,x-requested-with');
|
||||
next();
|
||||
});
|
||||
};
|
||||
return Server;
|
||||
}());
|
||||
exports.default = Server;
|
||||
//# sourceMappingURL=Server.js.map
|
||||
1
dist/Server/Server.js.map
vendored
Normal file
1
dist/Server/Server.js.map
vendored
Normal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,GAAV;QACE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,UAAC,OAAO,EAAE,QAAQ,EAAE,IAAI;YACnC,QAAQ,CAAC,MAAM,CAAC,6BAA6B,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,IAAI,GAAG,CAAC,CAAA;YAC7E,QAAQ,CAAC,MAAM,CAAC,8BAA8B,EAAE,wCAAwC,CAAC,CAAA;YACzF,QAAQ,CAAC,MAAM,CAAC,8BAA8B,EAAE,+BAA+B,CAAC,CAAA;YAChF,IAAI,EAAE,CAAA;QACR,CAAC,CAAC,CAAA;IACJ,CAAC;IACH,aAAC;AAAD,CAAC,AAxCD,IAwCC;AAED,kBAAe,MAAM,CAAA"}
|
||||
27
dist/index.js
vendored
Normal file
27
dist/index.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var http = require("http");
|
||||
var dotenv = require("dotenv");
|
||||
var Server_1 = require("./Server/Server.js");
|
||||
function main() {
|
||||
dotenv.config();
|
||||
var port = normalizePort(process.env.PORT || '5000');
|
||||
var webService = createServer();
|
||||
webService.listen(port, function () {
|
||||
console.log("Server is listening on " + port);
|
||||
});
|
||||
}
|
||||
function createServer() {
|
||||
var server = new Server_1.default();
|
||||
return http.createServer(server.app);
|
||||
}
|
||||
function normalizePort(port) {
|
||||
if (typeof port === 'string')
|
||||
return parseInt(port, 10);
|
||||
if (port >= 0)
|
||||
return port;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
main();
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
dist/index.js.map
vendored
Normal file
1
dist/index.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,2BAA4B;AAC5B,+BAAgC;AAChC,0CAAoC;AAEpC,SAAS,IAAI;IACX,MAAM,CAAC,MAAM,EAAE,CAAA;IACf,IAAM,IAAI,GAAW,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,MAAM,CAAC,CAAA;IAC9D,IAAM,UAAU,GAAgB,YAAY,EAAE,CAAA;IAE9C,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE;QACtB,OAAO,CAAC,GAAG,CAAC,4BAA0B,IAAM,CAAC,CAAA;IAC/C,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,YAAY;IACnB,IAAM,MAAM,GAAG,IAAI,gBAAM,EAAE,CAAA;IAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AACtC,CAAC;AAED,SAAS,aAAa,CAAE,IAAqB;IAC3C,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAG,OAAO,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IAExD,IAAI,IAAI,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;;QACrB,OAAO,CAAC,CAAA;AACf,CAAC;AAED,IAAI,EAAE,CAAA"}
|
||||
9
package-lock.json
generated
9
package-lock.json
generated
@ -32,6 +32,15 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/dotenv": {
|
||||
"version": "8.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/dotenv/-/dotenv-8.2.0.tgz",
|
||||
"integrity": "sha512-ylSC9GhfRH7m1EUXBXofhgx4lUWmFeQDINW5oLuS+gxWdfUeW4zJdeVTYVkexEW+e2VUvlZR2kGnGGipAWR7kw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"dotenv": "*"
|
||||
}
|
||||
},
|
||||
"@types/express": {
|
||||
"version": "4.17.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.8.tgz",
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
"typescript": "^4.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/dotenv": "^8.2.0",
|
||||
"@types/express": "^4.17.8",
|
||||
"@types/mongoose": "^5.7.36"
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"sourceMap": true,
|
||||
"target": "es2017",
|
||||
"target": "es5",
|
||||
"outDir": "./dist",
|
||||
"baseUrl": "./src"
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user