Skip to content

Commit ab046ff

Browse files
Revert "refactor: group auth related decorators (#8)" (#9)
This reverts commit b394fd2.
1 parent b394fd2 commit ab046ff

9 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Context, RouteSchema } from 'elysia';
2-
import type { GitHubDecorator } from './decorators/auth/github';
3-
import type { JwtDecorator } from './decorators/auth/jwt';
2+
import type { GitHubDecorator } from './decorators/github';
3+
import type { JwtDecorator } from './decorators/jwt';
44

55
export type ApiContext<Route extends RouteSchema = RouteSchema> = Context<Route> & {
66
github: GitHubDecorator;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { z } from 'zod';
2-
import { GitHubApiError } from '../../errors';
3-
import { assertNonNullish } from '../../utils/assert';
2+
import { GitHubApiError } from '../errors';
3+
import { assertNonNullish } from '../utils/assert';
44

55
const GitHubUserSchema = z.object({
66
id: z.number(),
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
jwtVerify,
88
SignJWT
99
} from 'jose';
10-
import { assertNonNullish } from '../../utils/assert';
10+
import { assertNonNullish } from '../utils/assert';
1111

1212
const PRIVATE_KEY_PEM_PATH = process.env.JWT_PRIVATE_KEY_PATH;
1313
const PUBLIC_KEY_PEM_PATH = process.env.JWT_PUBLIC_KEY_PATH;

src/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { cors } from '@elysiajs/cors';
22
import { openapi } from '@elysiajs/openapi';
33
import { Elysia } from 'elysia';
44
import packageJson from '../package.json';
5-
import { GitHubDecorator } from './decorators/auth/github';
6-
import { JwtDecorator } from './decorators/auth/jwt';
5+
import { GitHubDecorator } from './decorators/github';
6+
import { JwtDecorator } from './decorators/jwt';
77
import { GitHubApiError, GitHubAuthUnauthorizedError, NullishError } from './errors';
88
import {
99
GitHubAuthFinalizeSchema,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { afterEach, beforeEach, describe, expect, it, mock, spyOn } from 'bun:test';
2-
import { GitHubDecorator } from '../../../src/decorators/auth/github';
3-
import { GitHubApiError } from '../../../src/errors';
2+
import { GitHubDecorator } from '../../src/decorators/github';
3+
import { GitHubApiError } from '../../src/errors';
44

55
describe('decorators > github', () => {
66
let github: GitHubDecorator;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { beforeAll, describe, expect, it } from 'bun:test';
2-
import { JwtDecorator } from '../../../src/decorators/auth/jwt';
2+
import { JwtDecorator } from '../../src/decorators/jwt';
33

44
describe('decorators > jwt', () => {
55
let jwt: JwtDecorator;

test/handlers/auth/github.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { afterEach, describe, expect, it, mock } from 'bun:test';
22
import type { ApiContext } from '../../../src/context';
3-
import { JwtDecorator } from '../../../src/decorators/auth/jwt';
3+
import { JwtDecorator } from '../../../src/decorators/jwt';
44
import { githubAuthInit } from '../../../src/handlers/auth/github';
55

66
describe('handlers > auth > github', () => {

test/handlers/auth/jwks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it } from 'bun:test';
22
import type { ApiContext } from '../../../src/context';
3-
import { JwtDecorator } from '../../../src/decorators/auth/jwt';
3+
import { JwtDecorator } from '../../../src/decorators/jwt';
44
import { authJwks } from '../../../src/handlers/auth/jwks';
55

66
describe('handlers > auth > jwks', () => {

test/server.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('server', () => {
3333
expect(data.state).toBeString();
3434

3535
// Verify the state JWT is valid
36-
const { JwtDecorator } = await import('../src/decorators/auth/jwt');
36+
const { JwtDecorator } = await import('../src/decorators/jwt');
3737
const jwt = new JwtDecorator();
3838
const verified = await jwt.verify(data.state);
3939
expect(verified.valid).toBe(true);
@@ -82,7 +82,7 @@ describe('server', () => {
8282
}) as typeof fetch);
8383

8484
// Create valid state token
85-
const { JwtDecorator } = await import('../src/decorators/auth/jwt');
85+
const { JwtDecorator } = await import('../src/decorators/jwt');
8686
const jwt = new JwtDecorator();
8787
const stateToken = await jwt.signOAuthJwt({
8888
payload: {
@@ -144,7 +144,7 @@ describe('server', () => {
144144
});
145145

146146
it('should return 401 on state mismatch', async () => {
147-
const { JwtDecorator } = await import('../src/decorators/auth/jwt');
147+
const { JwtDecorator } = await import('../src/decorators/jwt');
148148
const jwt = new JwtDecorator();
149149
const stateToken = await jwt.signOAuthJwt({
150150
payload: { provider: 'github', token: 'a'.repeat(64), nonce: 'nonce' }

0 commit comments

Comments
 (0)