running api

This commit is contained in:
sneakers-the-rat 2023-07-24 16:15:27 -07:00
parent a7072e6130
commit bac7b6f275
6 changed files with 27 additions and 4 deletions

View file

@ -5,6 +5,7 @@
repo: https://git.jon-e.net/jonny/chatbridge
dest: "{{ chatbridge_user_home }}/chatbridge"
version: "HEAD"
# failed_when: "command_result.failed and 'Local modifications' not in command_result.msg"
register: command_result
failed_when: "command_result.failed and 'Local modifications' not in command_result.msg"

View file

@ -4,6 +4,7 @@
template:
src: chatbridge_env.j2
dest: "{{ chatbridge_user_home}}/.env"
mode: "600"
- name: create https nginx config
become: yes
@ -20,6 +21,7 @@
template:
src: nginx_chatbridge_http.conf.j2
dest: /etc/nginx/sites-available/chatbridge.conf
when:
- chatbridge_https is defined
- not chatbridge_https

View file

@ -14,11 +14,20 @@
system: true
- name: Create public directory and give permissions to www-data
become: yes
file:
mode: '660'
mode: '755'
state: directory
group: "www-data"
owner: "{{ chatbridge_user }}"
path: "{{ chatbridge_user_home }}/public"
- name: Chmod home directory
become: yes
file:
mode: '755'
state: directory
group: "www-data"

View file

@ -13,7 +13,7 @@ server {
}
location {{ chatbridge_webroot }}/ {
rewrite ^{{ chatbridge_webroot }}/?(.*)$ $1 break;
rewrite ^{{ chatbridge_webroot }}?(/.*)$ $1 break;
root {{ chatbridge_user_home }}/public;
try_files $uri $uri/ $uri/index.html =404;
}

View file

@ -3,7 +3,7 @@ import express, { NextFunction, Request, Response } from 'express';
import config from 'config';
import cors from 'cors';
import { AppDataSource } from './db/data-source';
import AppError from './errors/appError';

11
server/errors/appError.ts Normal file
View file

@ -0,0 +1,11 @@
export default class AppError extends Error {
status: string;
isOperational: boolean;
constructor(public statusCode: number = 500, public message: string) {
super(message);
this.status = `${statusCode}`.startsWith('4') ? 'fail' : 'error';
this.isOperational = true;
Error.captureStackTrace(this, this.constructor);
}
}