Pixie & Dixie API is the dark side of the Pixie & Dixie ultimate universe!
Checkout the [1] Pixie & Dixie Front-end for full setup.
Clone stuff obviously:
$ git clone [email protected]:Dorious/pixiedixie-api.git
And install what is necessary:
$ npm install
Copy config.example.json
file to your config.json
:
$ cp config.example.json config.json
Edit it in your favourite editor and add Giphy && Pixabay API keys where it's obvious (hint: "apiKey"
).
Inside config.json
you can change "port"
and then just:
$ npm start
> [email protected] start C:\Users\darius.arc\Projects\Git\pixiedixie-api
> ts-node-dev --no-notify --respawn --transpileOnly src/index.ts
Using ts-node version 8.6.2, typescript version 3.7.5
Setting up "/api/v1" API prefix...
Server running @ http://localhost:8001/api/v1
Go to [2] http://localhost:8001/api/v1 for basic API documentation.
$ npm run test
Wasn't really focused fully on TDD honestly. More prototype approach.
But just added some features like mocking axios queries.
Obviously you have installed everything from previous step, so now you can:
$ npm run build
$ npm run production
It will compile TS into ES6 and run the server.
You can also use Docker:
$ docker image build -t pixiedixie:1.0.1
$ docker container run --publish 8000:8000 --name pixiedixie-api pixiedixie:1.0.1
Some description what I did so far:
- NodeJS
- TypeScript
- Express
- Axios (moxios for mocking)
- Jest (with ts-jest preset)
As I wanted data sources to be easily added to the site I've implemented Adapter
pattern where each provider has own class (extended from abstract DataSourceAdapter) with proper interfaces.
Basically here you put your router responses methods.
Add them later in src/app.ts
like the others with getHandler
method.
NOTE: This could be refactor a lil bit because every route right now uses the same getHandler
method.
- Be more TS strict in some places like put return types of each function.
- DataSources some refactor. Some code is duplicated there and I could make.
- Some Token Authentication could be done.
- Error handling could be in some places better.
- Dynamic offset/count. The problem with multiple sources is that when you want to get 30 results you don't know will you get the same amount so sometimes you can have gaps. Need to find a nice way to fill that gaps.
- More documentation in the code.
- Others:
- Minify
dist
build.
- Minify