Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: make nix shell as development environment #76

Merged
merged 3 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
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
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
Loading