Skip to content

Commit

Permalink
initial mocked svcs
Browse files Browse the repository at this point in the history
  • Loading branch information
ignacionr committed Aug 24, 2016
1 parent e310916 commit fda2554
Show file tree
Hide file tree
Showing 15 changed files with 4,472 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/dist/index.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outDir": null,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
},
{
"name": "Attach to Process",
"type": "node",
"request": "attach",
"processId": "${command.PickProcess}",
"port": 5858,
"sourceMaps": false,
"outDir": null
}
]
}
16 changes: 16 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"args": [
"--no-color"
],
"tasks": [
{
"taskName": "default",
"isBuildCommand": true
}
]
}
21 changes: 21 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"use strict";
var express = require("express");
var bodyParser = require("body-parser");
var app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var port = process.env.PORT || 8080;
var switch_status = true;
var router = express.Router();
router.post('/login', function (req, res) {
res.json({ token: 'youmadeit' });
});
router.get('/switch', function (req, res) {
res.json({ status: switch_status });
});
router.post('/switch', function (req, res) {
switch_status = req.body.status;
res.json({ status: switch_status });
});
app.use('/', router);
app.listen(port);
9 changes: 9 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var gulp = require("gulp");
var ts = require("gulp-typescript");
var tsProject = ts.createProject("tsconfig.json");

gulp.task("default", function () {
return tsProject.src()
.pipe(ts(tsProject))
.js.pipe(gulp.dest("dist"));
});
33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "smartbnbkit-backend",
"version": "1.0.0",
"description": "The backend API for Toptal's Open Source Rental-Economy Hardware Kit",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/smartbnbkit/backend.git"
},
"keywords": [
"hardware",
"iot",
"backend"
],
"author": "The Toptal Hardware Community",
"license": "GPL-3.0",
"bugs": {
"url": "https://github.com/smartbnbkit/backend/issues"
},
"homepage": "https://github.com/smartbnbkit/backend#readme",
"dependencies": {
"body-parser": "^1.15.2",
"express": "^4.14.0"
},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-typescript": "^2.13.6",
"typescript": "^1.8.10"
}
}
28 changes: 28 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"use strict";

import express = require("express");
import bodyParser = require("body-parser");

let app = express();

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

var port = process.env.PORT || 8080;

let switch_status = true;

var router = express.Router();
router.post('/login', function(req, res) {
res.json({ token: 'youmadeit' });
});
router.get('/switch', function(req, res) {
res.json({ status: switch_status });
});
router.post('/switch', function(req, res) {
switch_status = req.body.status;
res.json({ status: switch_status });
});

app.use('/', router);
app.listen(port);
11 changes: 11 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"sourceMap": false
},
"exclude": [
"node_modules"
]
}
4 changes: 4 additions & 0 deletions typings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "smartbnbkit-backend",
"dependencies": {}
}
Loading

0 comments on commit fda2554

Please sign in to comment.