fastify-server-example icon indicating copy to clipboard operation
fastify-server-example copied to clipboard

product post added, cors replaced by fastify-cors and some other fixes

Open digital-codes opened this issue 4 years ago • 0 comments

Hi Carl. I made some update to your example, which I found quite helpfull to get started. I use an sqlite setup, which could be added to the .env.example maybe (didn't do this yet): TYPEORM_CONNECTION=sqlite TYPEORM_HOST=localhost TYPEORM_USERNAME=test TYPEORM_PASSWORD=test TYPEORM_DATABASE=test.db TYPEORM_SYNCHRONIZE=true TYPEORM_LOGGING=true

I also added a login option for JWT which now works when you go to http localhost:3000/login -a user:1234

You can then use the token like: http -v localhost:3000/products authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo0MiwiaWF0IjoxNjI5NjE4MzkyLCJleHAiOjE2Mjk2MjE5OTJ9.imP9SWSXaKEFEe-0ykKXpPmvyl2nBQzamuUGhV7uwS4"

And upload products like: http -v post localhost:3000/products Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo0MiwiaWF0IjoxNjI5NjE4MzkyLCJleHAiOjE2Mjk2MjE5OTJ9.imP9SWSXaKEFEe-0ykKXpPmvyl2nBQzamuUGhV7uwS4" name=test image=oe122enuen expires_in=300 unit="$"

Token expires after 1 hour ..

digital-codes avatar Aug 22 '21 08:08 digital-codes