feat: Split v1 and v2 apis
This commit is contained in:
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,5 +1,3 @@
|
||||
node_modules/
|
||||
.env
|
||||
package-lock.json
|
||||
.env
|
||||
migrate.js
|
||||
**/node_modules/
|
||||
**/.env
|
||||
**/package-lock.json
|
||||
|
||||
@@ -4,33 +4,96 @@ stages:
|
||||
- deploy
|
||||
|
||||
variables:
|
||||
PIPELINE_WORK_DIR: "./"
|
||||
DOCKERFILE_PATH: "./"
|
||||
API_CFG: "./config/default.json"
|
||||
CONTAINER_NAME: "eta-etaapi"
|
||||
PUBLIC_PORT: 7001
|
||||
PRIVATE_PORT: 3000
|
||||
PIPELINE_WORK_DIR_V1: "./v1"
|
||||
CONTAINER_NAME_V1: "eta-etaapi"
|
||||
PIPELINE_WORK_DIR_V2: "./v2"
|
||||
CONTAINER_NAME_V2: "eta-etaapiv2"
|
||||
PUBLIC_PORT_V1: 7001
|
||||
PRIVATE_PORT_V1: 3000
|
||||
PUBLIC_PORT_V2: 7002
|
||||
PRIVATE_PORT_V2: 3000
|
||||
|
||||
build-job:
|
||||
stage: build
|
||||
.generic_build_job: &generic_build_job
|
||||
script:
|
||||
- cd $PIPELINE_WORK_DIR
|
||||
- . ./scripts/ci_functions.sh
|
||||
- build_docker $CONTAINER_NAME
|
||||
only:
|
||||
- master
|
||||
|
||||
upload-job:
|
||||
stage: upload
|
||||
.generic_upload_job: &generic_upload_job
|
||||
script:
|
||||
- cd $PIPELINE_WORK_DIR
|
||||
- . ./scripts/ci_functions.sh
|
||||
- upload_image
|
||||
only:
|
||||
- master
|
||||
|
||||
deploy-job:
|
||||
stage: deploy
|
||||
.generic_deploy_job: &generic_deploy_job
|
||||
script:
|
||||
- cd $PIPELINE_WORK_DIR
|
||||
- . ./scripts/ci_functions.sh
|
||||
- deploy
|
||||
only:
|
||||
- master
|
||||
|
||||
|
||||
build-v1-job:
|
||||
stage: build
|
||||
needs: []
|
||||
variables:
|
||||
PIPELINE_WORK_DIR: "$PIPELINE_WORK_DIR_V1"
|
||||
CONTAINER_NAME: "$CONTAINER_NAME_V1"
|
||||
PUBLIC_PORT: "$PUBLIC_PORT_V1"
|
||||
PRIVATE_PORT: "$PRIVATE_PORT_V1"
|
||||
<<: *generic_build_job
|
||||
|
||||
build-v2-job:
|
||||
stage: build
|
||||
needs: []
|
||||
variables:
|
||||
PIPELINE_WORK_DIR: "$PIPELINE_WORK_DIR_V2"
|
||||
CONTAINER_NAME: "$CONTAINER_NAME_V2"
|
||||
PUBLIC_PORT: "$PUBLIC_PORT_V2"
|
||||
PRIVATE_PORT: "$PRIVATE_PORT_V2"
|
||||
<<: *generic_build_job
|
||||
|
||||
upload-v1-job:
|
||||
stage: upload
|
||||
needs: ["build-v1-job"]
|
||||
variables:
|
||||
PIPELINE_WORK_DIR: "$PIPELINE_WORK_DIR_V1"
|
||||
CONTAINER_NAME: "$CONTAINER_NAME_V1"
|
||||
PUBLIC_PORT: "$PUBLIC_PORT_V1"
|
||||
PRIVATE_PORT: "$PRIVATE_PORT_V1"
|
||||
<<: *generic_upload_job
|
||||
|
||||
upload-v2-job:
|
||||
stage: upload
|
||||
needs: ["build-v2-job"]
|
||||
variables:
|
||||
PIPELINE_WORK_DIR: "$PIPELINE_WORK_DIR_V2"
|
||||
CONTAINER_NAME: "$CONTAINER_NAME_V2"
|
||||
PUBLIC_PORT: "$PUBLIC_PORT_V2"
|
||||
PRIVATE_PORT: "$PRIVATE_PORT_V2"
|
||||
<<: *generic_upload_job
|
||||
|
||||
deploy-v1-job:
|
||||
stage: deploy
|
||||
needs: ["upload-v1-job"]
|
||||
variables:
|
||||
PIPELINE_WORK_DIR: "$PIPELINE_WORK_DIR_V1"
|
||||
CONTAINER_NAME: "$CONTAINER_NAME_V1"
|
||||
PUBLIC_PORT: "$PUBLIC_PORT_V1"
|
||||
PRIVATE_PORT: "$PRIVATE_PORT_V1"
|
||||
<<: *generic_deploy_job
|
||||
|
||||
deploy-v2-job:
|
||||
stage: deploy
|
||||
needs: ["upload-v2-job"]
|
||||
variables:
|
||||
PIPELINE_WORK_DIR: "$PIPELINE_WORK_DIR_V2"
|
||||
CONTAINER_NAME: "$CONTAINER_NAME_V2"
|
||||
PUBLIC_PORT: "$PUBLIC_PORT_V2"
|
||||
PRIVATE_PORT: "$PRIVATE_PORT_V2"
|
||||
<<: *generic_deploy_job
|
||||
|
||||
14
.vscode/tasks.json
vendored
14
.vscode/tasks.json
vendored
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "dev",
|
||||
"problemMatcher": [
|
||||
"$node-sass"
|
||||
],
|
||||
"label": "npm: dev",
|
||||
"detail": "nodemon src/"
|
||||
}
|
||||
]
|
||||
}
|
||||
41
scripts/migrate.js
Normal file
41
scripts/migrate.js
Normal file
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
require('dotenv').config();
|
||||
const { ROOT_PATH, LIB_PATH, API_CONFIG } = process.env;
|
||||
const apiConfig = require( `${ROOT_PATH}/${API_CONFIG}` );
|
||||
const { getModel } = require( './src/lib/Models' );
|
||||
const mongoose = require('mongoose');
|
||||
const Model = getModel('loads');
|
||||
|
||||
mongoose.connect(
|
||||
apiConfig.mongodb,
|
||||
{ useNewUrlParser: true }
|
||||
).then( ( val ) => {
|
||||
console.log( `MongoDB Connected : ${ apiConfig.mongodb }` );
|
||||
});//catch throw error so service stops!
|
||||
|
||||
async function migrate(){
|
||||
const list = await Model.find({
|
||||
"postedBy":"65f11b7c02030a15ebd59a8f"
|
||||
},"createdAt").sort("-createdAt").exec();
|
||||
// let list = await Model.find({ _id : [ "64fce4083f60cc00182470e0", "65efaffaa2029862cd6d90ef",
|
||||
// "65f2679402030a15ebd59d63",
|
||||
// "65f3a64902030a15ebd5a4f6",
|
||||
// "6610bbc756c2a72c91085d5c"]
|
||||
// }, "createdAt" );
|
||||
|
||||
for (const element of list ){
|
||||
console.log( element );
|
||||
console.log( new Date(element.createdAt) );
|
||||
}
|
||||
|
||||
const date = Date.now();
|
||||
// console.log( list.length , affected );
|
||||
await mongoose.disconnect();
|
||||
return "Done";
|
||||
}
|
||||
|
||||
migrate().then( (out)=>{
|
||||
console.log( out );
|
||||
} ).catch( (error) => {
|
||||
console.error( error );
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
SERVER_PORT=3000
|
||||
ROOT_PATH=/home/josepablocb/Documents/Work/EnRuta/SysS/ETAAPI
|
||||
ROOT_PATH=/mnt/d/Projects/WebDevWorkspace/ETAViaporte/etaapi/v1
|
||||
API_CONFIG=src/config/apiConfig_local.json
|
||||
############################
|
||||
# PATHS relative to ROOT
|
||||
@@ -6,7 +6,6 @@
|
||||
"scripts": {
|
||||
"start": "node src/",
|
||||
"dev": "nodemon src/",
|
||||
"dev3": "nodemon server/src/",
|
||||
"test": "mocha test/lib/handlers/proposals"
|
||||
},
|
||||
"repository": {
|
||||
0
scripts/ci_functions.sh → v1/scripts/ci_functions.sh
Executable file → Normal file
0
scripts/ci_functions.sh → v1/scripts/ci_functions.sh
Executable file → Normal file
17
v2/Dockerfile
Normal file
17
v2/Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
||||
# Use an official Python runtime as a parent image
|
||||
FROM node:18-alpine
|
||||
|
||||
# Set the working directory to /app
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the current directory contents into the container at /app
|
||||
COPY server /app/server
|
||||
COPY package.json /app
|
||||
COPY dotenv /app/.env
|
||||
|
||||
RUN apk add bash bash-completion vim
|
||||
RUN npm install --include=dev
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENTRYPOINT npm start
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user