From 0ac62bf03ae258311e812286d3c330fcbd104a76 Mon Sep 17 00:00:00 2001 From: Noah Spannbauer Date: Tue, 26 Nov 2024 19:35:31 -0600 Subject: [PATCH] changing api to azure function app --- api/.dockerignore | 1 + api/Dockerfile | 49 ++++----------------------------------- api/src/app.controller.ts | 2 +- api/src/main.ts | 1 + 4 files changed, 8 insertions(+), 45 deletions(-) diff --git a/api/.dockerignore b/api/.dockerignore index 79e6ea4..f75e16a 100644 --- a/api/.dockerignore +++ b/api/.dockerignore @@ -1,2 +1,3 @@ +local.settings.json node_modules test \ No newline at end of file diff --git a/api/Dockerfile b/api/Dockerfile index 3e4e719..4d1fb97 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,50 +1,11 @@ # To enable ssh & remote debugging on app service change the base image to the one below # FROM mcr.microsoft.com/azure-functions/node:4-node18-appservice -# FROM mcr.microsoft.com/azure-functions/node:4-node18 - -# ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ -# AzureFunctionsJobHost__Logging__Console__IsEnabled=true - -# COPY . /home/site/wwwroot - -# RUN cd /home/site/wwwroot && \ -# npm install - -# EXPOSE 7071 - -# CMD ["npm", "run", "start:azure"] - - - -# FROM mcr.microsoft.com/azure-functions/node:4-node18 AS build - -# WORKDIR /home/site/wwwroot - -# COPY . . - -# RUN npm install && \ -# npm run build - FROM mcr.microsoft.com/azure-functions/node:4-node18 -WORKDIR /home/site/wwwroot +ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ + AzureFunctionsJobHost__Logging__Console__IsEnabled=true -COPY . . +COPY . /home/site/wwwroot -RUN npm install -g azure-functions-core-tools@4 --unsafe-perm true -RUN npm install - -# ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ -# AzureFunctionsJobHost__Logging__Console__IsEnabled=true - # AzureFunctionsJobHost__extensions__cors__allowedOrigins="[\"*\"]" \ - # AzureFunctionsJobHost__extensions__cors__supportCredentials=false - - -# COPY --from=build /home/site/wwwroot/node_modules /home/site/wwwroot/node_modules -# COPY --from=build /home/site/wwwroot/dist /home/site/wwwroot/dist - -# EXPOSE 3000 - -# CMD ["node", "/home/site/wwwroot/dist/src/main.js"] - -CMD ["npm", "run", "start:azure"] \ No newline at end of file +RUN cd /home/site/wwwroot && \ + npm install \ No newline at end of file diff --git a/api/src/app.controller.ts b/api/src/app.controller.ts index 58421d0..b054f30 100644 --- a/api/src/app.controller.ts +++ b/api/src/app.controller.ts @@ -108,7 +108,7 @@ export class AppController { @Public() @Get('hello') - getHello(): string { + async getHello(): Promise { return this.appService.getHello(); } } diff --git a/api/src/main.ts b/api/src/main.ts index fc8500d..581cea1 100644 --- a/api/src/main.ts +++ b/api/src/main.ts @@ -8,6 +8,7 @@ async function bootstrap() { const httpService = new HttpService(); const app = await NestFactory.create(AppModule); + app.setGlobalPrefix('api'); app.useGlobalFilters(new HttpExceptionFilter()); httpService.axiosRef.interceptors.response.use( (response) => {