- NodeJS, Typescript, ExpressJS
- MongoDB on Cloud (Atlas)
- AWS S3 (AWS SDK)
- Automated Deployment on Heroku (triggered via push on master)
-
sudo npm install -g typescript
(IF not installed on your machine) -
tsc --init
-
npm init
-
npm install --save express
-
npm install --save body-parser
(Express 4.16+ versions have re-added the BodyParser again!) -
npm install --save-dev @types/node
-
npm install --save-dev @types/express
-
npm install --save-dev @types/body-parser
-
In
tsconfig.json
:"rootDir": "./src"
"outDir": "./dist"
(also change the package.json scripts)"moduleResolution": "node"
-
npm install --save-dev nodemon
-
npm install --save multer
-
npm install --save-dev @types/multer
-
npm install @aws-sdk/client-s3
-
npm install --save-dev dotenv
(Put it in the NPM RUN script and NOT on the code otherwise Heroku yells that the dependency is not found as it is a Dev dep package!) -
npm i oracledb
Orcale SODA -
npm install --save-dev @types/multer
tsc --watch
npm run serve
(in a parallel terminal)
- Problem 1:
- What: The API code did not run after deploying on Heroku
- Reason: Because Heroku looks at
npm start
script and there it expectsnode ...
and NOTnodemon ...
- Solution: I leave
npm start
for deployment and heroku and usenpm run serve
for local development.
-
To send file, For
multer
you should always use the NAME of the field you passed on the frontend to thenew FormData().append(NAME, ...)
And also you should add themultipart
header for FE-request. -
Because the upload process write files on system you should
sudo npm run serve
and before that you should run it from an admin account on your machine so:su <admin-username>
and then password.
https://www.oracle.com/database/technologies/appdev/quickstartnodejs.html#macos-tab
CANCELED: There's a large file in instantclient_19_8/
which needs Git LFS, but even if it's solved, this Instant Client is for MacOS, I'm not sure after deploying on Heroku it's gonna work. (Probabley Heroku has an instance of Linux!) I develop on MacOS so it makes the process very complicated. So I should go for another cloud db...
db.collection.insert()
is deprecated. Use instead.insertOne()
or.insertMany()