feat: Split v1 and v2 apis
This commit is contained in:
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,5 +1,3 @@
|
|||||||
node_modules/
|
**/node_modules/
|
||||||
.env
|
**/.env
|
||||||
package-lock.json
|
**/package-lock.json
|
||||||
.env
|
|
||||||
migrate.js
|
|
||||||
|
|||||||
@@ -4,33 +4,96 @@ stages:
|
|||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
PIPELINE_WORK_DIR: "./"
|
PIPELINE_WORK_DIR_V1: "./v1"
|
||||||
DOCKERFILE_PATH: "./"
|
CONTAINER_NAME_V1: "eta-etaapi"
|
||||||
API_CFG: "./config/default.json"
|
PIPELINE_WORK_DIR_V2: "./v2"
|
||||||
CONTAINER_NAME: "eta-etaapi"
|
CONTAINER_NAME_V2: "eta-etaapiv2"
|
||||||
PUBLIC_PORT: 7001
|
PUBLIC_PORT_V1: 7001
|
||||||
PRIVATE_PORT: 3000
|
PRIVATE_PORT_V1: 3000
|
||||||
|
PUBLIC_PORT_V2: 7002
|
||||||
|
PRIVATE_PORT_V2: 3000
|
||||||
|
|
||||||
build-job:
|
.generic_build_job: &generic_build_job
|
||||||
stage: build
|
|
||||||
script:
|
script:
|
||||||
|
- cd $PIPELINE_WORK_DIR
|
||||||
- . ./scripts/ci_functions.sh
|
- . ./scripts/ci_functions.sh
|
||||||
- build_docker $CONTAINER_NAME
|
- build_docker $CONTAINER_NAME
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
upload-job:
|
.generic_upload_job: &generic_upload_job
|
||||||
stage: upload
|
|
||||||
script:
|
script:
|
||||||
|
- cd $PIPELINE_WORK_DIR
|
||||||
- . ./scripts/ci_functions.sh
|
- . ./scripts/ci_functions.sh
|
||||||
- upload_image
|
- upload_image
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
deploy-job:
|
.generic_deploy_job: &generic_deploy_job
|
||||||
stage: deploy
|
|
||||||
script:
|
script:
|
||||||
|
- cd $PIPELINE_WORK_DIR
|
||||||
- . ./scripts/ci_functions.sh
|
- . ./scripts/ci_functions.sh
|
||||||
- deploy
|
- deploy
|
||||||
only:
|
only:
|
||||||
- master
|
- 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
|
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
|
API_CONFIG=src/config/apiConfig_local.json
|
||||||
############################
|
############################
|
||||||
# PATHS relative to ROOT
|
# PATHS relative to ROOT
|
||||||
@@ -6,7 +6,6 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node src/",
|
"start": "node src/",
|
||||||
"dev": "nodemon src/",
|
"dev": "nodemon src/",
|
||||||
"dev3": "nodemon server/src/",
|
|
||||||
"test": "mocha test/lib/handlers/proposals"
|
"test": "mocha test/lib/handlers/proposals"
|
||||||
},
|
},
|
||||||
"repository": {
|
"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