Skip to content

Commit

Permalink
lint: make happy
Browse files Browse the repository at this point in the history
  • Loading branch information
njfamirm committed Mar 2, 2025
1 parent 4c02872 commit 45d928d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 37 deletions.
5 changes: 1 addition & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"cSpell.words": [
"decap",
"nanotron"
]
"cSpell.words": ["decap", "nanotron"]
}
2 changes: 1 addition & 1 deletion src/lib/api-server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NanotronApiServer} from '@alwatr/nanotron'
import {NanotronApiServer} from '@alwatr/nanotron';

import {config} from '../config.js';

Expand Down
26 changes: 13 additions & 13 deletions src/route/auth.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { AuthorizationCode } from "simple-oauth2";
import { randomBytes } from "crypto";
import { apiServer } from "../lib/api-server.js";
import { config, logger } from "../config.js";
import {AuthorizationCode} from 'simple-oauth2';
import {randomBytes} from 'crypto';
import {apiServer} from '../lib/api-server.js';
import {config, logger} from '../config.js';

export const randomString = () => randomBytes(4).toString("hex");
export const randomString = () => randomBytes(4).toString('hex');

apiServer.defineRoute({
method: "GET",
url: "/auth",
method: 'GET',
url: '/auth',
handler: function () {
const host = this.headers.host;
const url = new URL(`https://${host}/${this.url}`);
const provider = url.searchParams.get("provider");
logger.logMethodArgs?.("get-auth", { host, url, provider });
const provider = url.searchParams.get('provider');
logger.logMethodArgs?.('get-auth', {host, url, provider});

if (provider !== "github") {
if (provider !== 'github') {
return {
ok: false,
statusCode: 400,
errorCode: "invalid_provider",
errorCode: 'invalid_provider',
};
}

Expand All @@ -33,9 +33,9 @@ apiServer.defineRoute({
state: randomString(),
});

logger.logProperty?.("authorizationUri", authorizationUri);
logger.logProperty?.('authorizationUri', authorizationUri);

this.serverResponse.raw_.setHeader("Location", authorizationUri);
this.serverResponse.raw_.setHeader('Location', authorizationUri);
return {
ok: true,
statusCode: 301,
Expand Down
28 changes: 14 additions & 14 deletions src/route/callback.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { AuthorizationCode } from "simple-oauth2";
import { config, logger } from "../config.js";
import { apiServer } from "../lib/api-server.js";
import {AuthorizationCode} from 'simple-oauth2';
import {config, logger} from '../config.js';
import {apiServer} from '../lib/api-server.js';

apiServer.defineRoute({
method: "GET",
url: "/callback",
method: 'GET',
url: '/callback',
handler: async function () {
const host = this.headers.host;
const url = new URL(`https://${host}/${this.url}`);
const provider = url.searchParams.get("provider");
const code = url.searchParams.get("code");
logger.logMethodArgs?.("get-callback", { host, url, provider });
const provider = url.searchParams.get('provider');
const code = url.searchParams.get('code');
logger.logMethodArgs?.('get-callback', {host, url, provider});

if (provider !== "github") {
if (provider !== 'github') {
return {
ok: false,
statusCode: 400,
errorCode: "invalid_provider",
errorCode: 'invalid_provider',
};
}

if (!code) {
return {
ok: false,
statusCode: 400,
errorCode: "require_code",
errorCode: 'require_code',
};
}

Expand All @@ -38,9 +38,9 @@ apiServer.defineRoute({
};

const accessToken = await client.getToken(tokenParams);
const token = accessToken.token["access_token"] as string;
const token = accessToken.token['access_token'] as string;

this.serverResponse.reply(renderBody("success", token));
this.serverResponse.reply(renderBody('success', token));

return {
ok: true,
Expand All @@ -54,7 +54,7 @@ function renderBody(status: string, token?: string) {
<script>
const receiveMessage = (message) => {
window.opener.postMessage(
'authorization:github:${status}:${JSON.stringify({ token })}',
'authorization:github:${status}:${JSON.stringify({token})}',
message.origin
);
Expand Down
10 changes: 5 additions & 5 deletions src/route/home.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { apiServer } from "../lib/api-server.js";
import {apiServer} from '../lib/api-server.js';

apiServer.defineRoute({
method: "GET",
url: "/",
method: 'GET',
url: '/',
handler: function () {
this.serverResponse.replyJson({
ok: true,
data: {
app: "..:: Decap CMS Backend Microservice ::..",
message: "Hello",
app: '..:: Decap CMS Backend Microservice ::..',
message: 'Hello',
},
});
},
Expand Down

0 comments on commit 45d928d

Please sign in to comment.