Skip to content

Commit

Permalink
🧱 (api): Chore api
Browse files Browse the repository at this point in the history
Define base structure of the api folder , and restructure the docker compose , add Makefile
  • Loading branch information
phareal committed Dec 17, 2022
1 parent 5bbc190 commit 332da40
Show file tree
Hide file tree
Showing 13 changed files with 1,903 additions and 12 deletions.
8 changes: 8 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
APP_NAME="symfony-advanced"
APP_VERSION=dev
APP_ENV=dev

# Domain
DOMAIN=2aud.io.localhost
API_SUBDOMAIN=api
API_PORT=8000
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea
.env
/src/api/.pnpm-store/
/src/api/dist/
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.PHONY: start-env

start-env:
docker compose up
stop-env:
docker compose down

dive-into-api:
docker-compose exec webapp bash
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h1 align="center">2aud.io</h1>

<p align="center">
<strong>Text to speech for African languages </strong>
<strong>Text to speech Platform </strong>
</p>

<p align="center">
Expand All @@ -28,11 +28,11 @@
<!-- ABOUT THE PROJECT -->
## 📜 About the project

**2aud.io** is a plateform to provide a text to speech and speech to text platform for african languages first for the Togo and if the project grows we will add more langages
**2aud.io** is a plateform to provide a text to speech and speech to text platform


## ⁉️ Purpose of the project
The main goal of this project are
The main goal of this project are
Here's why:
* To have a deep understanding of some concept like sound recognition , data processing and other cool stuffs
* Improve my programming and analytics skills :smile:
Expand All @@ -49,7 +49,7 @@ Here's why:

### Built With

The main technlogies i used to create this app are
The main technlogies i used to create this app are

* [React.js](https://reactjs.org/)
* [fastify](https://www.fastify.io/)
Expand All @@ -65,13 +65,13 @@ Here's why:
- [ ] Grap all necessary data
- [ ] Create Application
- [ ] Create dockerfile
- [ ] Setup CI/CD
- [ ] Setup CI/CD
- [ ] Backend
- [ ] Define routes
- [ ] Define folder structure (Architecture)
- [ ] (etc)
- [ ] (test)
- [ ] Front End
- [ ] Front End
- [ ] Define folder structure (Architecture)
- [ ] Build components
- [ ] Build pages
Expand All @@ -80,12 +80,12 @@ Here's why:
- [ ] Release the first beta for users
- [ ] Fix issues
- [ ] Multi-language Support
- [ ] French
- [ ] Deutsch
- [ ] Japanese
- [ ] (Add more locale african language)
- [ ] (etc)
- [ ] French
- [ ] Deutsch
- [ ] Japanese
- [ ] (Add more locale african language)
- [ ] (etc)


<!-- LICENSE -->
## 📄 License
Expand Down
52 changes: 52 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

# This Docker Compose file should only be used for your development environment!
version: '3.5'

services:

traefik:
image: traefik:2.4
command:
- --providers.docker
- --providers.docker.exposedByDefault=false
- --api.dashboard=true
- --api.insecure=true
labels:
- traefik.enable=true
- traefik.http.routers.traefik_dashboard_router.rule=Host(`traefik.$DOMAIN`)
- traefik.http.routers.traefik_dashboard_router.service=traefik_dashboard_service
- traefik.http.services.traefik_dashboard_service.loadbalancer.server.port=8080
ports:
- "80:80"
volumes:
- /var/run/docker.sock:/var/run/docker.sock

api:
build:
context: "./src/api"
labels:
- traefik.enable=true
- traefik.http.routers.api_router.rule=Host(`$API_SUBDOMAIN.$DOMAIN`)
- traefik.http.routers.api_router.service=api_service
- traefik.http.services.api_service.loadbalancer.server.port=$API_PORT
ports:
- "${API_PORT}:${API_PORT}"
command: pnpm dev:api
environment:
# Docker image.
# ---------------------
STARTUP_COMMAND_1: "pnpm install"
STARTUP_COMMAND_2: "pnpm dev:build"
APP_NAME: "$APP_NAME"
APP_VERSION: "$APP_VERSION"
API_PORT: "$API_PORT"

volumes:
- ./src/api:/usr/src/app
- ~/.ssh:/home/docker/.ssh:ro

networks:
default:
name: 2aud.io-network


Empty file added src/api/.env.dist
Empty file.
12 changes: 12 additions & 0 deletions src/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM thecodingmachine/nodejs:v2-18-bullseye

USER root

RUN apt-get update -y &&\
apt-get install openssh-client -y

RUN npm install -g pnpm

EXPOSE 8000

USER docker
5 changes: 5 additions & 0 deletions src/api/core/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare namespace NodeJS {
export interface ProcessEnv {
API_PORT: string;
}
}
25 changes: 25 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import fastify from 'fastify'
import * as process from "process";

const server = fastify({
logger:true
})

server.get('/ping', async (request, reply) => {
return reply.send({
'ping':'pong'
})
})

const API_PORT = Number(process.env.API_PORT)



server.listen({ port:API_PORT, host:'0.0.0.0'}, (err, address) => {
if (err) {
console.error(err)
process.exit(1)
}
console.log(`Server listening at yes ${API_PORT}`)
})

7 changes: 7 additions & 0 deletions src/api/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"verbose": false,
"watch": ["."],
"ext": "ts,js,json",
"ignore": [".git", "node_modules", "/", "/dist"],
"exec": "ts-node index.ts"
}
27 changes: 27 additions & 0 deletions src/api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "api",
"version": "1.0.0",
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"dev:build": "tsc",
"dev:api": "tsc-watch --noClear --onSuccess \"nodemon\"",
"preview": ""
},
"dependencies": {
"fastify": "^4.10.2"
},
"devDependencies": {
"eslint": "^8.30.0",
"nodemon": "^2.0.20",
"typescript": "^4.9.4",
"@types/node": "^18.11.16",
"ts-node": "^10.9.1",
"tsc-watch": "^5.0.3",
"@typescript-eslint/eslint-plugin": "^5.46.1",
"@typescript-eslint/parser": "^5.46.1",
"concurrently": "^7.6.0",
"prettier": "^2.8.1",
"dotenv": "^16.0.3"
}
}
Loading

0 comments on commit 332da40

Please sign in to comment.