remove API prefix
This commit is contained in:
parent
da008ea658
commit
0696ba8084
|
@ -27,7 +27,6 @@ module.exports.create = function (xconfx, apiFactories, apiDeps) {
|
||||||
function isThisClientAllowedToUseThisPkg(myConf, clientUrih, pkgId) {
|
function isThisClientAllowedToUseThisPkg(myConf, clientUrih, pkgId) {
|
||||||
var appApiGrantsPath = path.join(myConf.appApiGrantsPath, clientUrih);
|
var appApiGrantsPath = path.join(myConf.appApiGrantsPath, clientUrih);
|
||||||
|
|
||||||
console.log('sanity exists?', appApiGrantsPath);
|
|
||||||
return fs.readFileAsync(appApiGrantsPath, 'utf8').then(function (text) {
|
return fs.readFileAsync(appApiGrantsPath, 'utf8').then(function (text) {
|
||||||
console.log('sanity', text);
|
console.log('sanity', text);
|
||||||
return text.trim().split(/\n/);
|
return text.trim().split(/\n/);
|
||||||
|
@ -57,6 +56,7 @@ module.exports.create = function (xconfx, apiFactories, apiDeps) {
|
||||||
function loadRestHelper(myConf, pkgId) {
|
function loadRestHelper(myConf, pkgId) {
|
||||||
var pkgPath = path.join(myConf.restPath, pkgId);
|
var pkgPath = path.join(myConf.restPath, pkgId);
|
||||||
|
|
||||||
|
// TODO should not require package.json. Should work with files alone.
|
||||||
return fs.readFileAsync(path.join(pkgPath, 'package.json'), 'utf8').then(function (text) {
|
return fs.readFileAsync(path.join(pkgPath, 'package.json'), 'utf8').then(function (text) {
|
||||||
var pkg = JSON.parse(text);
|
var pkg = JSON.parse(text);
|
||||||
var deps = {};
|
var deps = {};
|
||||||
|
@ -85,6 +85,13 @@ module.exports.create = function (xconfx, apiFactories, apiDeps) {
|
||||||
|
|
||||||
console.log('DEBUG pkgPath', pkgPath);
|
console.log('DEBUG pkgPath', pkgPath);
|
||||||
myApp = express();
|
myApp = express();
|
||||||
|
myApp.use('/', function preHandler(req, res, next) {
|
||||||
|
req.originalUrl = req.originalUrl || req.url;
|
||||||
|
// "/path/api/com.example/hello".replace(/.*\/api\//, '').replace(/([^\/]*\/+)/, '/') => '/hello'
|
||||||
|
req.url = req.url.replace(/\/api\//, '').replace(/.*\/api\//, '').replace(/([^\/]*\/+)/, '/');
|
||||||
|
console.log('[prehandler] req.url', req.url);
|
||||||
|
next();
|
||||||
|
});
|
||||||
//
|
//
|
||||||
// TODO handle /accounts/:accountId
|
// TODO handle /accounts/:accountId
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue