Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Add set update channel script, make sure more routes are protected #121

Merged
merged 2 commits into from
Jun 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions routes/v2/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ router.post('/update', auth.jwt, async (ctx, next) => {
await next();
});

router.get('/backup-status', async (ctx, next) => {
router.get('/backup-status', auth.jwt, async (ctx, next) => {
ctx.body = await systemLogic.getBackupStatus();
await next();
});
Expand Down Expand Up @@ -111,21 +111,21 @@ router.get('/memory', async (ctx, next) => {
await next();
});

router.get('/temperature', async (ctx, next) => {
router.get('/temperature', auth.jwt, async (ctx, next) => {
ctx.body = {
temperature: await diskLogic.readJsonStatusFile('temperature'),
};
await next();
});

router.get('/uptime', async (ctx, next) => {
router.get('/uptime', auth.jwt, async (ctx, next) => {
ctx.body = {
uptime: await diskLogic.readJsonStatusFile('uptime'),
};
await next();
});

router.get('/disk-type', async (ctx, next) => {
router.get('/disk-type', auth.jwt, async (ctx, next) => {
let externalStorage: 'nvme' | 'unknown' = 'unknown';
try {
const externalStorageUnformatted = await diskLogic.readTextStatusFile(
Expand All @@ -143,13 +143,20 @@ router.get('/disk-type', async (ctx, next) => {
await next();
});

router.put('/update-channel', async (ctx, next) => {
router.put('/update-channel', auth.jwt, async (ctx, next) => {
typeHelper.isString(ctx.body.channel, ctx);
await systemLogic.setUpdateChannel(ctx.body.channel as string);
await next();
});

router.get('/', async (ctx, next) => {
router.get('/update-channel', auth.jwt, async (ctx, next) => {
ctx.body = {
channel: constants.GITHUB_BRANCH,
};
await next();
});

router.get('/', auth.jwt, async (ctx, next) => {
ctx.body = {os: constants.IS_CITADEL_OS ? 'Citadel OS' : 'unknown'};
await next();
});
Expand Down