forked from madefor/postal-code-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
116 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM node:16.13-buster-slim | ||
|
||
WORKDIR /home/node/app | ||
COPY lib lib | ||
COPY package.json . | ||
COPY gulpfile.js . | ||
RUN npm install | ||
RUN npm install -g http-server | ||
RUN npm run build | ||
RUN npm prune --production | ||
|
||
CMD [ "npm", "start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: "3.7" | ||
services: | ||
app: | ||
build: . | ||
volumes: | ||
- .:/home/node/app | ||
- /home/node/app/node_modules | ||
- /home/node/app/lib/api | ||
ports: | ||
- "3000:3000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
const csv = require( 'comma-separated-values' ); | ||
const fs = require( 'fs' ) | ||
const path = require( 'path' ) | ||
const csv = require("comma-separated-values"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
fs.readFile( 'api/KEN_ALL_ROME.CSV', 'utf8', ( err, data ) => { | ||
fs.readFile("lib/api/KEN_ALL_ROME.CSV", "utf8", (err, data) => { | ||
if (err) throw err; | ||
|
||
const res = new csv( data, { | ||
cast: [ 'String', 'String', 'String', 'String', 'String', 'String', 'String' ] | ||
} ).parse(); | ||
const res = new csv(data, { | ||
cast: [ | ||
"String", | ||
"String", | ||
"String", | ||
"String", | ||
"String", | ||
"String", | ||
"String", | ||
], | ||
}).parse(); | ||
|
||
for ( var i = 0; i < res.length; i++ ) { | ||
const p = res[i][0].trim() | ||
fs.statSync( path.join( 'api', 'v1', | ||
p.replace( /^([0-9]{3}).*/, '$1' ), | ||
p.replace( /.*([0-9]{4})$/, '$1' ) + '.json' ) ) | ||
for (var i = 0; i < res.length; i++) { | ||
const p = res[i][0].trim(); | ||
fs.statSync( | ||
path.join( | ||
"api", | ||
"v1", | ||
p.replace(/^([0-9]{3}).*/, "$1"), | ||
p.replace(/.*([0-9]{4})$/, "$1") + ".json" | ||
) | ||
); | ||
} | ||
}); |