Skip to content

Commit

Permalink
Merge pull request #243 from Sensotrend/shutdown
Browse files Browse the repository at this point in the history
Disable API
  • Loading branch information
mrinnetmaki committed Nov 30, 2023
2 parents 48d6843 + 43af075 commit 46bd4b0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 48 deletions.
65 changes: 23 additions & 42 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,7 @@ async function isUserAuthenticated (req, res, next) {
}

app.getAsync('/loggedin', isUserAuthenticated, async function (req, res) {

const user = await env.userProvider.findUserById(req.session.user.user_id);

if (!user.email) {
res.redirect('/emailverification/generateRequest');
} else {
const pageEnv = { apiURL: env.apiURL };

res.render('secret.ejs', {
user: user,
pageEnv,
});
}
res.status(451).send('');;
});

app.deleteAsync('/api/deleteuser', async function (req, res) {
Expand Down Expand Up @@ -108,41 +96,34 @@ app.deleteAsync('/api/deleteuser', async function (req, res) {
res.redirect('/deleted');
});

function send451(req, res) {
res.status(451).send('');;
}

app.get('/api*', send451);
app.put('/api*', send451);
app.post('/api*', send451);
app.get('/auth/*', send451);
app.post('/auth/*', send451);
app.get('/emailverification*', send451);
app.post('/emailverification*', send451);
app.get('/fiphr*', send451);
app.post('/fiphr*', send451);
app.get('/nsconsent*', send451);
app.post('/nsconsent*', send451);
app.get('/pebble', send451);
app.get('/tp*', send451);
app.put('/tp*', send451);
app.post('/tp*', send451);


// Logout route
app.get('/logout', (req, res) => {
req.session.destroy();
// res.render('loggedout.ejs');
res.status(200).json({ status: 'OK' });
});

/// Kanta authentication
app.use('/fiphr', env.oauthProvider);
app.use('/auth/kanta', env.oauthProvider);
////

let nsrest = NSRestService(env);
app.use('/api/v1', nsrest);
app.use('/pebble', nsrest);

let tidepoolService = TidepoolRESTService(env);

app.use('/tpupload', tidepoolService.uploadApp);
app.use('/tpapi', tidepoolService.APIapp);
app.use('/tpdata', tidepoolService.dataApp);

env.logger.info('TidepoolRESTService started');

let nightscoutService = NightscoutViewConsentService(env);

app.use('/nsconsent', nightscoutService);

env.logger.info('Nightscout access consent Service started');

let emailService = EmailVerificationService(env);

app.use('/emailverification', emailService);

env.logger.info('Email verification Service started');

//production mode
if (process.env.NODE_ENV === 'production') {
Expand All @@ -159,7 +140,7 @@ app.use(function(err, req, res, next) {
env.logger.error('Problem serving URL ' + req.originalUrl);
env.logger.error(err);
env.logger.error(err.stack);
res.status(500).send('There was a problem handling your request');
res.status(500).send('');
}
});

Expand Down
6 changes: 4 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nightscout-fhir-connect",
"version": "1.4.28",
"version": "1.4.29",
"description": "Nightscout REST API provider for FHIR PHRs",
"repository": "https://github.com/sensotrend/nightscout-fi",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion tests/fhirclient.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const testPatient = {
]
};

describe('FHIRClient', function () {
describe.skip('FHIRClient', function () {

it('should create a sample patient', async function () {
try {
Expand Down
2 changes: 1 addition & 1 deletion tests/mongo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const env = envModule();
let Auth = env.userProvider;


describe('auth_module_test', function () {
describe.skip('auth_module_test', function () {

it('should store and load users', async function () {

Expand Down
2 changes: 1 addition & 1 deletion tests/skipservice.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const env = envModule();
let Auth = env.userProvider;


describe('device last uploaded date service', function () {
describe.skip('device last uploaded date service', function () {


it('should not find nonexistent profiles', async function () {
Expand Down

0 comments on commit 46bd4b0

Please sign in to comment.