Coder Social home page Coder Social logo

loopback-todolist's Introduction

nodejs-loopback-scaffold

This project is originally generated using lb4 command from @loopback/cli. See Getting started with LoopBack 4 for more details.

It has been slightly tailored as a template for appsody.

LoopBack

It also includes a JAM stack application using Gridsome.

I have also adapted a todo app in Svelte that only uses id, title, isComplete - so no todolists - and a todo can be created with just these fields. Is not part of a todo list.

To run the rest server appsody run

Note that using appsody allows the app to be accessed from external browser. But appsody is now cancelled. Can also use npm start --host 0.0.0.0 for external access

curl commands for testing from windows NB: password has to be at least 8 char curl -X POST -H "Content-Type: application/json" -d "{"email":"[email protected]", "password":"12345678"}" https://mint20-loopback4:3000/signup { "id":"5bccc71d-38d3-463b-b081-5f82589636c4", "email":"[email protected]" }

But I have now added authorization so I need to add roles to the user (admin, developers ) curl -X POST -H "Content-Type: application/json" -d "{"email":"[email protected]", "password":"12345678", "roles":["developer"]}" https://mint20-loopback4:3000/signup

curl -k -X POST -H "Content-Type: application/json" -d "{"email":"[email protected]", "password":"12345678"}" https://mint20-loopback4:3000/users/login

{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjAyNjIzOTZhLTk4NmMtNDdmZS04ZGIxLTQzOTFlMDM2NDc1ZCIsImVtYWlsIjoibWFyaWFAZW1haWwuY29tIiwiaWF0IjoxNjE2Njc3NDY3LCJleHAiOjE2MTY2OTkwNjd9.eLDZiZz4N53aTv5nHwPE2a_2i14LN9GU6aUb22PoOgI"}

[Container] Try https://[::1]:3000/ping [Container] NORRIS: user login: user is {"id":"23cbfef0-eef5-4872-9805-f8d51529d655","email":"[email protected]","roles":["developer"]} [Container] NORRIS: user login: userProfile is {"id":"23cbfef0-eef5-4872-9805-f8d51529d655","email":"[email protected]","roles":["developer"]} [Container] NORRIS: user login: token is eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjIzY2JmZWYwLWVlZjUtNDg3Mi05ODA1LWY4ZDUxNTI5ZDY1NSIsInJvbGVzIjpbImRldmVsb3BlciJdLCJpYXQiOjE2MjQzNTU0NDgsImV4cCI6MTYyNDM3NzA0OH0.owSqxKwBWvAWbJn8zTKm4vAA1b5xeT1J1gJbhKWK4Yw [Container] NORRIS: entering basic authorizor [Container] NORRIS: Ctx length is: 1 [Container] NORRIS: Ctx roles length is: 0 [Container] NORRIS: Ctx[0] is: {"id":"23cbfef0-eef5-4872-9805-f8d51529d655","roles":["developer"],"type":"USER"} [Container] NORRIS: user is: {"id":"23cbfef0-eef5-4872-9805-f8d51529d655","roles":["developer"]} [Container] NORRIS: current user object is: {"roles":["developer"]} [Container] NORRIS: what is in roles: ["developer"] [Container] NORRIS: current role includes admin or developer

Actually the todo list controller is NOT protected by authenticate. Only the Todo controller is. So infact though the next curl works, it is not necessary. It is necessary for todo

curl -H "Content-Type: application/json" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjAyNjIzOTZhLTk4NmMtNDdmZS04ZGIxLTQzOTFlMDM2NDc1ZCIsImVtYWlsIjoibWFyaWFAZW1haWwuY29tIiwiaWF0IjoxNjE2Njc3NDY3LCJleHAiOjE2MTY2OTkwNjd9.eLDZiZz4N53aTv5nHwPE2a_2i14LN9GU6aUb22PoOgI" https://mint20-loopback4:3000/todo-lists

works! curl -k https://88.111.150.77:3000/todo-lists curl https://mint20-loopback4:3000/todo-lists [ { "id": 1, "title": "Sith lord's check list", "colour": "red" }, { "id": 2, "title": "My daily chores", "colour": "blue" }, { "id": 100, "title": "grocery list" } ]

curl https://mint20-loopback4:3000/todos [ { "id": 1, "title": "Take over the galaxy", "desc": "MWAHAHAHAHAHAHAHAHAHAHAHAHAMWAHAHAHAHAHAHAHAHAHAHAHAHA", "todoListId": 1 }, { "id": 2, "title": "destroy alderaan", "desc": "Make sure there are no survivors left!", "todoListId": 1 }, { "id": 3, "title": "play space invaders", "desc": "Become the very best!", "todoListId": 2 }, { "id": 4, "title": "crush rebel scum", "desc": "Every.Last.One.", "todoListId": 1 }, { "id": 100, "title": "get eggs", "isComplete": false, "todoListId": 100 } ]

curl -X POST -H "Content-Type: application/json" -d "{"title":"gardening list"}" https://mint20-loopback4:3000/todo-lists { "id": 101, "title": "gardening list" }

curl -X POST -H "Content-Type: application/json" -d "{"title":"continue tar on shed", "isComplete":false}" https://mint20-loopback4:3000/todo-lists/101/todos { "id": 101, "title": "continue tar on shed", "isComplete": false, "todoListId": 101 }

curl https://mint20-loopback4:3000/todo-lists/101/todos [ { "id": 101, "title": "continue tar on shed", "isComplete": false, "todoListId": 101 } ]

curl https://mint20-loopback4:3000/todo-lists/101 { "id": 101, "title": "gardening list" }

curl -H "Content-Type: application/json" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjIzY2JmZWYwLWVlZjUtNDg3Mi05ODA1LWY4ZDUxNTI5ZDY1NSIsImVtYWlsIjoibWFyaWFAZW1haWwuY29tIiwiaWF0IjoxNjI4NTg4NTE4LCJleHAiOjE2Mjg2MTAxMTh9.4aQVfsruB4SpaAxKZY_8LdGQGfMoQ0T0sOObrFPWdV0" https://mint20-loopback4:3000/todos?filter=%7B%0A%20%20%22where%22%3A%20%7B%0A%20%20%20%20%22todoListId%22%3A%20101%0A%20%20%7D%0A%7D

can we instead call https://mint20-loopback4:3000/users/{userId}/todos ??

To run the gridsome app (in other window) cd gridsome/todolist gridsome develop

The code is hardcoded to use a server named mint20-loopback4 running on 8080

This is a play project

loopback-todolist's People

Contributors

norricorp avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.