Skip to content

Commit

Permalink
Merge pull request #76 from hapakaien/build/nix-shell
Browse files Browse the repository at this point in the history
build: make nix shell as development environment
  • Loading branch information
heyhusen authored Nov 19, 2023
2 parents d0f826a + e278b0d commit d18d64d
Show file tree
Hide file tree
Showing 49 changed files with 6,771 additions and 7,758 deletions.
28 changes: 17 additions & 11 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,49 +22,55 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['18']
node: ['18', '20']
env:
FOLDER: node

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'yarn'
cache-dependency-path: ${{ env.FOLDER }}/yarn.lock
cache: 'pnpm'
cache-dependency-path: ${{ env.FOLDER }}/pnpm-lock.yaml

- name: Install dependencies
run: |
cd ${{ env.FOLDER }}
yarn install
pnpm i
- name: Run linter
run: |
cd ${{ env.FOLDER }}
yarn lint
pnpm lint
- name: Run prettier
run: |
cd ${{ env.FOLDER }}
yarn prettier
pnpm prettier
- name: Run build
run: |
cd ${{ env.FOLDER }}
yarn build
pnpm build
- name: Run tests
run: |
cd ${{ env.FOLDER }}
cp .env.example .env
docker compose up -d
sleep 10s
yarn migrate:up
yarn seed:run
yarn test
pnpm migrate:up
pnpm seed:run
pnpm test
docker compose down -v
15 changes: 15 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [

]
}
46 changes: 4 additions & 42 deletions node/__tests__/app.test.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,17 @@
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
import type {
BearerTokenError,
JsonApiError,
} from '../src/adapters/interfaces/http.interface';
import { logIn, request } from './setup';
import { afterAll, describe, expect, test } from 'vitest';
import type { JsonApiError } from '../src/adapters/interfaces/http.interface';
import { request } from './setup';
import { close } from './teardown';

let accessToken: string;

beforeAll(async () => {
const { accessToken: access } = await logIn();

accessToken = access;
});

afterAll(async () => {
await close();
});

describe('GET /', () => {
test('should return unauthorized error if authorization header missing', async () => {
const response = await request
.get('/')
.set('Accept', 'application/vnd.api+json');

expect(response.status).toEqual<number>(400);
expect(response.body).toEqual<BearerTokenError>({
error: 'invalid_request',
error_description:
'The request is missing a required authorization header.',
});
});

test('should return unauthorized error if token missing', async () => {
const response = await request
.get('/')
.set('Accept', 'application/vnd.api+json')
.auth('', { type: 'bearer' });

expect(response.status).toEqual<number>(401);
expect(response.body).toEqual<BearerTokenError>({
error: 'invalid_token',
error_description: 'The token is malformed.',
});
});

test('should return hello world', async () => {
const response = await request
.get('/')
.set('Accept', 'application/vnd.api+json')
.auth(accessToken, { type: 'bearer' });
.set('Accept', 'application/vnd.api+json');

expect(response.status).toEqual<number>(200);
expect(response.body).toEqual<string>('Hello world!');
Expand Down
Loading

0 comments on commit d18d64d

Please sign in to comment.