Skip to content

Commit

Permalink
Merge pull request #45 from akbarsaputrait/develop
Browse files Browse the repository at this point in the history
v24.07.10.00
  • Loading branch information
akbarsaputrait authored Jul 9, 2024
2 parents 8a354cc + 844b703 commit bc07839
Show file tree
Hide file tree
Showing 97 changed files with 4,289 additions and 510 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build and Push to Docker Hub

on:
push:
branches:
- develop
- master

jobs:
build-and-push:
runs-on: ubuntu-latest
environment: docker

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set Docker tag
id: set-tag
run: |
if [[ ${{ github.ref }} == 'refs/heads/master' ]]; then
echo "DOCKER_TAG=latest" >> $GITHUB_OUTPUT
else
echo "DOCKER_TAG=develop" >> $GITHUB_OUTPUT
fi
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: akbarsaputrait/ordero-api:${{ steps.set-tag.outputs.DOCKER_TAG }}
10 changes: 6 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml",
"editor.defaultFoldingRangeProvider": "redhat.vscode-yaml"
}
"editor.codeActionsOnSave": {
"source.fixAll": "always",
"source.organizeImports": "always"
},
"editor.tabSize": 2,
"editor.indentSize": "tabSize"
}
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16.13.1-alpine AS BUILD_IMAGE
FROM node:16.14.0-alpine AS build_image

# couchbase sdk requirements
RUN apk update && \
Expand All @@ -20,7 +20,7 @@ RUN yarn lint
# build application
RUN yarn build

FROM node:16.13.1-alpine
FROM node:16.14.0-alpine

# Python
RUN apk update && \
Expand All @@ -34,7 +34,7 @@ RUN apk update && \

# Timezone
RUN apk add --no-cache tzdata
ENV TZ UTC
ENV TZ=UTC

# Installs latest Chromium (77) package.
RUN apk add --no-cache \
Expand All @@ -47,13 +47,13 @@ RUN apk add --no-cache \
ttf-freefont

# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium-browser
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

WORKDIR /usr/src/app

# copy from build image
COPY --from=BUILD_IMAGE /usr/src/app ./
COPY --from=build_image /usr/src/app ./

EXPOSE 3000

Expand Down
12 changes: 8 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ services:

api-local:
container_name: ordero-api-local
image: 'ordero-api-local:latest'
image: 'ordero-api-local:develop'
restart: on-failure
environment:
TZ: '${TZ}'
Expand Down Expand Up @@ -91,14 +91,18 @@ services:
AWS_REGION: '${AWS_REGION}'
AWS_SECRET_ACCESS_KEY: '${AWS_SECRET_ACCESS_KEY}'
SENTRY_DSN: '${SENTRY_DSN}'
SOCKET_TYPE: '${SOCKET_TYPE}'
TWILLIO_SID: '${TWILLIO_SID}'
TWILLIO_TOKEN: '${TWILLIO_TOKEN}'
TWILLIO_SERVICE: '${TWILLIO_SERVICE}'
volumes:
- 'ordero:/api'
ports:
- '4002:3000'
- '${PORT_LOCAL}:3000'
expose:
- '3000'
networks:
net:
order_net:
ipv4_address: '${NETWORK_IP_LOCAL}'

volumes:
Expand All @@ -107,5 +111,5 @@ volumes:
driver: local

networks:
net:
order_net:
external: true
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
"aws-sdk": "^2.817.0",
"axios": "^1.6.7",
"bcryptjs": "^2.4.3",
"bwip-js": "^3.0.2",
"class-transformer": "0.3.2",
"convert-html-to-pdf": "^1.0.1",
"dayjs": "^1.11.4",
"dotenv": "^16.0.1",
"express-useragent": "^1.0.15",
Expand All @@ -63,7 +65,7 @@
"libphonenumber-js": "^1.10.12",
"lodash": "^4.17.21",
"mysql-import": "^5.0.21",
"mysql2": "^2.3.3",
"mysql2": "^3.10.2",
"nest-router": "^1.0.9",
"nest-winston": "^1.7.0",
"node-cache": "^5.1.2",
Expand All @@ -80,7 +82,7 @@
"simple-encryptor": "^4.0.0",
"slug": "^8.2.3",
"twilio": "^3.54.1",
"typeorm": "^0.3.7",
"typeorm": "^0.3.20",
"ulid": "^2.3.0",
"uuid": "^8.3.2",
"validatorjs": "^3.22.1",
Expand Down
Binary file added public/files/1715363520-tables-label.pdf
Binary file not shown.
Binary file added public/files/1715363558-tables-label.pdf
Binary file not shown.
Binary file added public/files/1715363617-tables-label.pdf
Binary file not shown.
Binary file added public/files/1715363683-tables-label.pdf
Binary file not shown.
Binary file added public/files/1715363705-tables-label.pdf
Binary file not shown.
Binary file added public/files/1715363753-tables-label.pdf
Binary file not shown.
Binary file added public/files/1715363799-tables-label.pdf
Binary file not shown.
38 changes: 38 additions & 0 deletions src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { Quero } from '@core/decorators/quero.decorator';
import base64url from '@lib/helpers/base64.helper';
import { config } from '@lib/helpers/config.helper';
import { Controller, Get, Res } from '@nestjs/common';
import * as fs from 'fs';
import { lookup } from 'mime-types';
import * as path from 'path';

@Controller()
export class AppController {
Expand All @@ -11,4 +17,36 @@ export class AppController {
favicon(@Res() response): string {
return response.noContent();
}

@Get('/files')
getFiles(@Quero() quero, @Res() response): string {
if (!quero.view) {
return response.status(302).redirect('/error?code=404');
}

const file = base64url.decode(quero.view);

const regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
if (regexp.test(file)) {
return response.render('iframe', { name: 'Market Label', url: file });
}

if (!fs.existsSync(file)) {
return response.status(302).redirect('/error?code=404');
}

const mime = lookup(file);
const uri = file.replace(config.getPublicPath(), '');
const name = path.basename(uri);
if (['application/pdf', 'text/html'].includes(mime)) {
return response.render('iframe', { name, url: `${config.getAssetURI()}${uri}` });
}

return response
.headers({
'Content-Type': mime,
'Content-Disposition': `attachment; filename=${name}`,
})
.send(fs.readFileSync(file));
}
}
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { routes } from './app.routes';
import { CustomerModule } from './app/customer/customer.module';
import { OwnerModule } from './app/owner/owner.module';
import { RestaurantModule } from './app/restaurant/restaurant.module';
import { StaffModule } from './app/staff/staff.module';

@Module({
imports: [
Expand All @@ -20,6 +21,7 @@ import { RestaurantModule } from './app/restaurant/restaurant.module';
OwnerModule,
RestaurantModule,
CustomerModule,
StaffModule,
],
controllers: [AppController],
providers: [SocketioGateway],
Expand Down
72 changes: 71 additions & 1 deletion src/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
import { Routes } from 'nest-router';
import type { Routes } from 'nest-router';
import { CustomerAuthModule } from './app/customer/auth/auth.module';
import { CustomerModule } from './app/customer/customer.module';
import { CustomerOrderModule } from './app/customer/order/order.module';
import { CustomerTableModule } from './app/customer/table/table.module';
import { OwnerAuthModule } from './app/owner/auth/auth.module';
import { OwnerModule } from './app/owner/owner.module';
import { OwnerProfileModule } from './app/owner/profile/profile.module';
import { OwnerCategoryModule } from './app/owner/restaurant/category/category.module';
import { OwnerLocationModule } from './app/owner/restaurant/location/location.module';
import { OwnerNotificationModule } from './app/owner/restaurant/notification/notification.module';
import { OwnerOrderModule } from './app/owner/restaurant/order/order.module';
import { OwnerProductModule } from './app/owner/restaurant/product/product.module';
import { OwnerRestaurantModule } from './app/owner/restaurant/restaurant.module';
import { OwnerStaffModule } from './app/owner/restaurant/staff/staff.module';
import { OwnerStockModule } from './app/owner/restaurant/stock/stock.module';
import { OwnerTableModule } from './app/owner/restaurant/table/table.module';
import { OwnerVariantModule } from './app/owner/restaurant/variant/variant.module';
import { RestaurantModule } from './app/restaurant/restaurant.module';
import { StaffAuthModule } from './app/staff/auth/auth.module';
import { StaffProfileModule } from './app/staff/profile/profile.module';
import { StaffCategoryModule } from './app/staff/restaurant/category/category.module';
import { StafffNotificationModule } from './app/staff/restaurant/notification/notification.module';
import { StaffOrderModule } from './app/staff/restaurant/order/order.module';
import { StaffProductModule } from './app/staff/restaurant/product/product.module';
import { StaffRestaurantModule } from './app/staff/restaurant/restaurant.module';
import { StaffStockModule } from './app/staff/restaurant/stock/stock.module';
import { StaffTableModule } from './app/staff/restaurant/table/table.module';
import { StaffVariantModule } from './app/staff/restaurant/variant/variant.module';
import { StaffModule } from './app/staff/staff.module';

export const routes: Routes = [
// { path: '/auth', module: AuthModule },
Expand Down Expand Up @@ -56,10 +70,62 @@ export const routes: Routes = [
path: '/:restaurant_id/stocks',
module: OwnerStockModule,
},
{
path: '/:restaurant_id/orders',
module: OwnerOrderModule,
},
{
path: '/:restaurant_id/notifications',
module: OwnerNotificationModule,
},
],
},
],
},

{
path: '/staff',
module: StaffModule,
children: [
{ path: '/auth', module: StaffAuthModule },
{ path: '/me', module: StaffProfileModule },
{
path: '/restaurants',
module: StaffRestaurantModule,
children: [
{
path: '/:restaurant_id/orders',
module: StaffOrderModule,
},
{
path: '/:restaurant_id/stocks',
module: StaffStockModule,
},
{
path: '/:restaurant_id/tables',
module: StaffTableModule,
},
{
path: '/:restaurant_id/categories',
module: StaffCategoryModule,
},
{
path: '/:restaurant_id/variants',
module: StaffVariantModule,
},
{
path: '/:restaurant_id/products',
module: StaffProductModule,
},
{
path: '/:restaurant_id/notifications',
module: StafffNotificationModule,
},
],
},
],
},

{
path: '/restaurants',
module: RestaurantModule,
Expand All @@ -76,6 +142,10 @@ export const routes: Routes = [
path: '/orders',
module: CustomerOrderModule,
},
{
path: '/tables',
module: CustomerTableModule,
},
],
},
];
3 changes: 2 additions & 1 deletion src/app/customer/customer.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { Module } from '@nestjs/common';
import { CustomerAuthModule } from './auth/auth.module';
import { CustomerController } from './customer.controller';
import { CustomerOrderModule } from './order/order.module';
import { CustomerTableModule } from './table/table.module';

@Module({
imports: [CustomerAuthModule, CustomerOrderModule],
imports: [CustomerAuthModule, CustomerOrderModule, CustomerTableModule],
controllers: [CustomerController],
providers: [],
})
Expand Down
2 changes: 1 addition & 1 deletion src/app/customer/order/detail.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AuthGuard } from '@core/guards/auth.guard';
import { Customer } from '@db/entities/core/customer.entity';
import { Order, OrderStatus } from '@db/entities/core/order.entity';
import { Table, TableStatus } from '@db/entities/owner/table.entity';
import { OrderTransformer } from '@db/transformers/order.tranformer';
import { OrderTransformer } from '@db/transformers/order.transformer';
import { ValidationException } from '@lib/exceptions/validation.exception';
import { Validator } from '@lib/helpers/validator.helper';
import AppDataSource from '@lib/typeorm/datasource.typeorm';
Expand Down
Loading

0 comments on commit bc07839

Please sign in to comment.