Skip to content

Commit

Permalink
Use /home/ as root for minit
Browse files Browse the repository at this point in the history
  • Loading branch information
cdebost committed May 29, 2018
1 parent a88eba5 commit 618639d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const routes = require('./routes');

const app = express();

routes(app);
routes(app, '/home/');

console.log('Listening on port 80');
app.listen(80);
7 changes: 4 additions & 3 deletions routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
const cors = require('cors');
const bodyParser = require('body-parser');
const Minit = require('./minit');
const path = require('path');

const MINIT_PATH = '/usr/local/bin/minit';

module.exports = (app) => {
module.exports = (app, home) => {
app.use(cors());
app.use(bodyParser.json());

Expand All @@ -18,13 +19,13 @@ module.exports = (app) => {
})));

app.use((req, res, next) => {
const path = req.query.path;
const pathArgument = path.join(home, req.query.path);
if (!path) {
res.status(400).json({
error: 'path query is required'
});
}
res.locals.path = path;
res.locals.path = pathArgument;
next();
});

Expand Down
9 changes: 5 additions & 4 deletions test/api-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const fs = require('fs');
const path = require('path');

const SPEC_FS_HOME = '/tmp/minit-service-spec/';
const SPEC_PATH_QUERY = 'minit-service-spec';

describe("Minit service", () => {
let app;
Expand All @@ -18,13 +19,13 @@ describe("Minit service", () => {

beforeEach(() => {
app = express();
routes(app);
routes(app, '/tmp/');
});

describe('POST /app', () => {
it('creates an app', (done) => {
supertest(app)
.post(`/app/myapp?path=${encodeURI(SPEC_FS_HOME)}`)
.post(`/app/myapp?path=${encodeURI(SPEC_PATH_QUERY)}`)
.expect(200)
.end((err) => {
if (err) return done(err);
Expand All @@ -44,7 +45,7 @@ describe("Minit service", () => {
const uiDirectory = path.join(SPEC_FS_HOME, 'ui');
fs.mkdirSync(uiDirectory);
supertest(app)
.post(`/component/mycomponent?path=${encodeURI(SPEC_FS_HOME)}`)
.post(`/component/mycomponent?path=${encodeURI(SPEC_PATH_QUERY)}`)
.expect(200)
.end((err) => {
if (err) return done(err);
Expand All @@ -59,7 +60,7 @@ describe("Minit service", () => {
describe('POST /module', () => {
it('creates a module', (done) => {
supertest(app)
.post(`/module/mymodule?path=${encodeURI(SPEC_FS_HOME)}`)
.post(`/module/mymodule?path=${encodeURI(SPEC_PATH_QUERY)}`)
.expect(200)
.end((err) => {
if (err) return done(err);
Expand Down

0 comments on commit 618639d

Please sign in to comment.