Beispiel #1
0
router.get('/:country', function (req, res) {

    res.json({
        users: api.getApiPath() + api.usersPath + '/' + req.params.country,
        locations: api.getApiPath() + api.locationsPath + '/' + req.params.country,
        languages: api.getApiPath() + api.languagesPath + '/' + req.params.country,
    });

});
Beispiel #2
0
            _.keys(continents.europe.countries).forEach(function(country) {

                continents.europe.countries[country].links = {
                    details: api.getApiPath() + api.countriesPath + '/' + country,
                }

            });
Beispiel #3
0
    self.createRoutes = function() {
        //self.routes = { };
        //
        //self.routes['/asciimo'] = function(req, res) {
        //    var link = "http://i.imgur.com/kmbjB.png";
        //    res.send("<html><body><img src='" + link + "'></body></html>");
        //};
        //
        //self.routes['/'] = function(req, res) {
        //    res.setHeader('Content-Type', 'text/html');
        //    res.send(self.cache_get('index.html') );
        //};

        self.app.use(express.static(__dirname + '/../build'));

        self.app.use(inputValidators);
        self.app.use(memoryCache({
            useClones: false,
            checkperiod: 0,
            cacheAll: true
        }));

        self.app.use(api.getApiPath() + api.usersPath, users);
        self.app.use(api.getApiPath() + api.languagesPath, languages);
        self.app.use(api.getApiPath() + api.locationsPath, locations);
        self.app.use(api.getApiPath() + api.countriesPath, countries);

        // catch 404 and forward to error handler
        self.app.use(function(req, res, next) {
            var err = new Error('Not Found');
            err.status = 404;
            next(err);
        });

        self.app.use(function(err, req, res, next) {
            res.status(err.status || 500);
            res.json({
                message: err.message,
                error: {}
            });
        });
    };
Beispiel #4
0
        .then(function (continents) {
            _.keys(continents.europe.countries).forEach(function(country) {

                continents.europe.countries[country].links = {
                    details: api.getApiPath() + api.countriesPath + '/' + country,
                }

            });
            var resBody = {
                continents: continents,
                links: {
                    allUsers: api.getApiPath() + api.usersPath
                }
            };
            res.json(resBody);
        });