├── GOLANG-GIN ├── Config │ └── Database.go ├── Controllers │ └── Book.go ├── Models │ ├── Book.go │ └── BookModel.go ├── Routes │ └── Routes.go ├── go.mod ├── go.sum ├── main.go └── readme.md ├── GOLANG-MUX ├── .gitignore ├── LICENSE ├── README.md ├── assets │ └── books.csv ├── datastore │ ├── datastore.go │ └── memory.go ├── go.mod ├── go.sum ├── loader │ └── loader.go ├── manifest.yml ├── routes.go └── server.go ├── LARAVEL-PASSPORT ├── .env ├── .env.example ├── .gitignore.txt ├── app │ ├── Console │ │ └── Kernel.php │ ├── Exceptions │ │ └── Handler.php │ ├── Http │ │ ├── Controllers │ │ │ ├── API │ │ │ │ ├── AuthController.php │ │ │ │ └── PropertyController.php │ │ │ └── Controller.php │ │ ├── Kernel.php │ │ ├── Middleware │ │ │ ├── Authenticate.php │ │ │ ├── CheckForMaintenanceMode.php │ │ │ ├── EncryptCookies.php │ │ │ ├── RedirectIfAuthenticated.php │ │ │ ├── TrimStrings.php │ │ │ ├── TrustHosts.php │ │ │ ├── TrustProxies.php │ │ │ └── VerifyCsrfToken.php │ │ └── Resources │ │ │ └── PropertyResource.php │ ├── Property.php │ ├── Providers │ │ ├── AppServiceProvider.php │ │ ├── AuthServiceProvider.php │ │ ├── BroadcastServiceProvider.php │ │ ├── EventServiceProvider.php │ │ └── RouteServiceProvider.php │ └── User.php ├── bootstrap │ ├── app.php │ └── cache │ │ └── .gitignore ├── composer.json ├── config │ ├── app.php │ ├── auth.php │ ├── broadcasting.php │ ├── cache.php │ ├── cors.php │ ├── database.php │ ├── filesystems.php │ ├── hashing.php │ ├── logging.php │ ├── mail.php │ ├── queue.php │ ├── services.php │ ├── session.php │ └── view.php ├── database │ ├── .gitignore │ ├── factories │ │ └── UserFactory.php │ ├── migrations │ │ ├── 2014_10_12_000000_create_users_table.php │ │ ├── 2014_10_12_100000_create_password_resets_table.php │ │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ │ └── 2020_12_27_061132_create_properties_table.php │ └── seeds │ │ └── DatabaseSeeder.php ├── package.json ├── public │ ├── .htaccess │ ├── favicon.ico │ ├── index.php │ ├── robots.txt │ └── web.config ├── readme.md ├── resources │ ├── js │ │ ├── app.js │ │ └── bootstrap.js │ ├── lang │ │ └── en │ │ │ ├── auth.php │ │ │ ├── pagination.php │ │ │ ├── passwords.php │ │ │ └── validation.php │ ├── sass │ │ └── app.scss │ └── views │ │ └── welcome.blade.php ├── routes │ ├── api.php │ ├── channels.php │ ├── console.php │ └── web.php ├── server.php ├── storage │ ├── app │ │ ├── .gitignore │ │ └── public │ │ │ └── .gitignore │ ├── framework │ │ ├── .gitignore │ │ ├── cache │ │ │ ├── .gitignore │ │ │ └── data │ │ │ │ └── .gitignore │ │ ├── sessions │ │ │ └── .gitignore │ │ ├── testing │ │ │ └── .gitignore │ │ └── views │ │ │ └── .gitignore │ ├── logs │ │ └── .gitignore │ ├── oauth-private.key │ └── oauth-public.key ├── tests │ ├── CreatesApplication.php │ ├── Feature │ │ └── ExampleTest.php │ ├── TestCase.php │ └── Unit │ │ └── ExampleTest.php └── webpack.mix.js ├── LICENSE ├── NODEJS-EXPRESS-MYSQL ├── .gitignore ├── README.md ├── app │ ├── config │ │ └── db.config.js │ ├── controllers │ │ └── property.controller.js │ ├── models │ │ ├── db.js │ │ └── property.model.js │ └── routes │ │ └── property.routes.js ├── package.json └── server.js ├── NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH ├── .gitignore ├── README.md ├── app │ ├── config │ │ ├── auth.config.js │ │ └── db.config.js │ ├── controllers │ │ ├── auth.controller.js │ │ ├── property.controller copy.js │ │ ├── property.controller.js │ │ └── user.controller.js │ ├── middleware │ │ ├── authJwt.js │ │ ├── index.js │ │ └── verifySignUp.js │ ├── models │ │ ├── index.js │ │ ├── property.model.js │ │ ├── role.model.js │ │ └── user.model.js │ └── routes │ │ ├── auth.routes.js │ │ ├── property.routes.js │ │ └── user.routes.js ├── package.json └── server.js ├── PHP-OOPS ├── book.class.php ├── composer.json ├── config │ ├── DatabasImport.sql │ └── Database.php ├── index.php ├── readme.md ├── readme.txt └── test │ ├── CreateBook.php │ ├── DeleteBook.php │ ├── ReadBook.php │ ├── ReadBookSingle.php │ └── UpdateBook.php ├── PYTHON-DJANGO-REST-FRAMEWORK ├── db.sqlite3 ├── manage.py ├── msite │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-38.pyc │ │ ├── settings.cpython-38.pyc │ │ ├── urls.cpython-38.pyc │ │ └── wsgi.cpython-38.pyc │ ├── asgi.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── readme.md ├── readme.md.bak └── rest │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-38.pyc │ ├── admin.cpython-38.pyc │ ├── apps.cpython-38.pyc │ ├── models.cpython-38.pyc │ ├── serializers.cpython-38.pyc │ ├── urls.cpython-38.pyc │ └── views.cpython-38.pyc │ ├── admin.py │ ├── apps.py │ ├── migrations │ ├── 0001_initial.py │ ├── 0002_book.py │ ├── 0003_auto_20201207_0231.py │ ├── 0004_auto_20201207_0257.py │ ├── 0005_auto_20201207_0325.py │ ├── __init__.py │ └── __pycache__ │ │ ├── 0001_initial.cpython-38.pyc │ │ ├── 0002_book.cpython-38.pyc │ │ ├── 0003_auto_20201207_0231.cpython-38.pyc │ │ ├── 0004_auto_20201207_0257.cpython-38.pyc │ │ ├── 0005_auto_20201207_0325.cpython-38.pyc │ │ └── __init__.cpython-38.pyc │ ├── models.py │ ├── serializers.py │ ├── tests.py │ ├── urls.py │ └── views.py ├── PYTHON ├── app.py ├── auth.png ├── data.db ├── data_old.db ├── db.py ├── images │ ├── Build REST api.png │ ├── get-books.png │ └── list-of-endpoints.png ├── models │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-38.pyc │ │ ├── book.cpython-38.pyc │ │ ├── item.cpython-38.pyc │ │ ├── store.cpython-38.pyc │ │ └── user.cpython-38.pyc │ ├── book.py │ ├── store.py │ └── user.py ├── postman-collections │ └── Python Rest API.postman_collection.json ├── readme.md ├── resources │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-38.pyc │ │ ├── book.cpython-38.pyc │ │ ├── item.cpython-38.pyc │ │ ├── store.cpython-38.pyc │ │ └── user.cpython-38.pyc │ ├── book.py │ ├── store.py │ └── user.py └── security.py ├── README.md └── images ├── BUILD-REST-API-laravel.jpg ├── Build REST api.png ├── Build-REST-API-USING-GO-MUX.png ├── Create-REST-API-with-php-oops-1.png ├── Create-REST-API-with-php-oops-10.png ├── Create-REST-API-with-php-oops-2.png ├── Create-REST-API-with-php-oops-3.png ├── Create-REST-API-with-php-oops-4.png ├── Create-REST-API-with-php-oops-5.png ├── Create-REST-API-with-php-oops-6.png ├── Create-REST-API-with-php-oops-7.png ├── Create-REST-API-with-php-oops-8.png ├── Create-REST-API-with-php-oops-9.png ├── Django-REST-API.png ├── GO_GIN_MAiN.png ├── Go-installation.png ├── Login.png ├── NodeJS-Express-Mysql-REST-API.jpg ├── NodeJS-test-1.png ├── NodeJs-test-10.png ├── NodeJs-test-2.png ├── NodeJs-test-3.png ├── NodeJs-test-4.png ├── NodeJs-test-5.png ├── NodeJs-test-6.png ├── NodeJs-test-7.png ├── NodeJs-test-8.png ├── NodeJs-test-9.png ├── Nodejs-Jwt-1.png ├── Nodejs-Jwt-10.png ├── Nodejs-Jwt-11.png ├── Nodejs-Jwt-12.png ├── Nodejs-Jwt-13.png ├── Nodejs-Jwt-14.png ├── Nodejs-Jwt-15.png ├── Nodejs-Jwt-16.png ├── Nodejs-Jwt-17.png ├── Nodejs-Jwt-2.png ├── Nodejs-Jwt-3.png ├── Nodejs-Jwt-4.png ├── Nodejs-Jwt-5.png ├── Nodejs-Jwt-6.png ├── Nodejs-Jwt-7.png ├── Nodejs-Jwt-8.png ├── Nodejs-Jwt-9.png ├── Nodejs-file-folder.png ├── Nodejs-server-up-browser.png ├── Property-create.png ├── REST-API-WITH-PHP-MYSQL.png ├── Register-keys.png ├── Register.png ├── django-local-server-up.png ├── django-restframework-books.png ├── django-restframework-stores.png ├── go-gin1.png ├── go-gin2.png ├── go-gin3.png ├── go-gin4.png ├── go-gin5.png ├── go-gin6.png ├── go-gin7.png ├── go-mux-1.png ├── go-mux-2.png ├── go-version.png ├── go.png ├── laravel-1.png ├── laravel-2.png ├── login-keys.png ├── node-server.png ├── nodejs-server-up.png ├── property-delete.png ├── property-fetch.png ├── property-update.png └── token.png /GOLANG-GIN/Config/Database.go: -------------------------------------------------------------------------------- 1 | package Config 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/jinzhu/gorm" 7 | ) 8 | 9 | var DB *gorm.DB 10 | 11 | // DBConfig represents db configuration 12 | type DBConfig struct { 13 | Host string 14 | Port int 15 | User string 16 | DBName string 17 | Password string 18 | } 19 | 20 | func BuildDBConfig() *DBConfig { 21 | dbConfig := DBConfig{ 22 | Host: "localhost", 23 | Port: 3306, 24 | User: "root", 25 | Password: "", 26 | DBName: "book-store", 27 | } 28 | return &dbConfig 29 | } 30 | 31 | func DbURL(dbConfig *DBConfig) string { 32 | return fmt.Sprintf( 33 | "%s:%s@tcp(%s:%d)/%s?charset=utf8&parseTime=True&loc=Local", 34 | dbConfig.User, 35 | dbConfig.Password, 36 | dbConfig.Host, 37 | dbConfig.Port, 38 | dbConfig.DBName, 39 | ) 40 | } 41 | -------------------------------------------------------------------------------- /GOLANG-GIN/Controllers/Book.go: -------------------------------------------------------------------------------- 1 | package Controllers 2 | 3 | import ( 4 | "first-api/Models" 5 | "fmt" 6 | "net/http" 7 | 8 | "github.com/gin-gonic/gin" 9 | ) 10 | 11 | //GetBooks ... Get all books 12 | func GetBooks(c *gin.Context) { 13 | var book []Models.Book 14 | err := Models.GetAllBooks(&book) 15 | if err != nil { 16 | c.AbortWithStatus(http.StatusNotFound) 17 | } else { 18 | c.JSON(http.StatusOK, book) 19 | } 20 | } 21 | 22 | //CreateBook ... Create Book 23 | func CreateBook(c *gin.Context) { 24 | var book Models.Book 25 | c.BindJSON(&book) 26 | err := Models.CreateBook(&book) 27 | if err != nil { 28 | fmt.Println(err.Error()) 29 | c.AbortWithStatus(http.StatusNotFound) 30 | } else { 31 | c.JSON(http.StatusOK, book) 32 | } 33 | } 34 | 35 | //GetBookByID ... Get the book by id 36 | func GetBookByID(c *gin.Context) { 37 | id := c.Params.ByName("id") 38 | var book Models.Book 39 | err := Models.GetBookByID(&book, id) 40 | if err != nil { 41 | c.AbortWithStatus(http.StatusNotFound) 42 | } else { 43 | c.JSON(http.StatusOK, book) 44 | } 45 | } 46 | 47 | //UpdateBook ... Update the book information 48 | func UpdateBook(c *gin.Context) { 49 | var book Models.Book 50 | id := c.Params.ByName("id") 51 | err := Models.GetBookByID(&book, id) 52 | if err != nil { 53 | c.JSON(http.StatusNotFound, book) 54 | } 55 | c.BindJSON(&book) 56 | err = Models.UpdateBook(&book, id) 57 | if err != nil { 58 | c.AbortWithStatus(http.StatusNotFound) 59 | } else { 60 | c.JSON(http.StatusOK, book) 61 | } 62 | } 63 | 64 | //DeleteBook ... Delete the book 65 | func DeleteBook(c *gin.Context) { 66 | var book Models.Book 67 | id := c.Params.ByName("id") 68 | err := Models.DeleteBook(&book, id) 69 | if err != nil { 70 | c.AbortWithStatus(http.StatusNotFound) 71 | } else { 72 | c.JSON(http.StatusOK, gin.H{"id" + id: "is deleted"}) 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /GOLANG-GIN/Models/Book.go: -------------------------------------------------------------------------------- 1 | package Models 2 | 3 | import ( 4 | "first-api/Config" 5 | "fmt" 6 | 7 | _ "github.com/go-sql-driver/mysql" 8 | ) 9 | 10 | //GetAllBooks Fetch all book data 11 | func GetAllBooks(book *[]Book) (err error) { 12 | if err = Config.DB.Find(book).Error; err != nil { 13 | return err 14 | } 15 | return nil 16 | } 17 | 18 | //CreateBook ... Insert New data 19 | func CreateBook(book *Book) (err error) { 20 | if err = Config.DB.Create(book).Error; err != nil { 21 | return err 22 | } 23 | return nil 24 | } 25 | 26 | //GetBookByID ... Fetch only one book by Id 27 | func GetBookByID(book *Book, id string) (err error) { 28 | if err = Config.DB.Where("id = ?", id).First(book).Error; err != nil { 29 | return err 30 | } 31 | return nil 32 | } 33 | 34 | //UpdateBook ... Update book 35 | func UpdateBook(book *Book, id string) (err error) { 36 | fmt.Println(book) 37 | Config.DB.Save(book) 38 | return nil 39 | } 40 | 41 | //DeleteBook ... Delete book 42 | func DeleteBook(book *Book, id string) (err error) { 43 | Config.DB.Where("id = ?", id).Delete(book) 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /GOLANG-GIN/Models/BookModel.go: -------------------------------------------------------------------------------- 1 | package Models 2 | 3 | import "time" 4 | 5 | type Book struct { 6 | Id uint `json:"id"` 7 | title string `json:"title"` 8 | Author string `json:"author"` 9 | Description string `json:"description"` 10 | Price float64 `json:"price"` 11 | Isbn string `json:"isbn"` 12 | Release_date time.Time `json:"release_date"` 13 | } 14 | 15 | func (b *Book) TableName() string { 16 | return "book" 17 | } 18 | -------------------------------------------------------------------------------- /GOLANG-GIN/Routes/Routes.go: -------------------------------------------------------------------------------- 1 | package Routes 2 | 3 | import ( 4 | "first-api/Controllers" 5 | 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | //SetupRouter ... Configure routes 10 | func SetupRouter() *gin.Engine { 11 | r := gin.Default() 12 | grp1 := r.Group("/book-store") 13 | { 14 | grp1.GET("book", Controllers.GetBooks) 15 | grp1.POST("book", Controllers.CreateBook) 16 | grp1.GET("book/:id", Controllers.GetBookByID) 17 | grp1.PUT("book/:id", Controllers.UpdateBook) 18 | grp1.DELETE("book/:id", Controllers.DeleteBook) 19 | } 20 | return r 21 | } 22 | -------------------------------------------------------------------------------- /GOLANG-GIN/go.mod: -------------------------------------------------------------------------------- 1 | module first-api 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/gin-gonic/gin v1.6.2 7 | github.com/go-sql-driver/mysql v1.5.0 8 | github.com/jinzhu/gorm v1.9.12 9 | ) 10 | -------------------------------------------------------------------------------- /GOLANG-GIN/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "first-api/Config" 5 | "first-api/Models" 6 | "first-api/Routes" 7 | "fmt" 8 | 9 | "github.com/jinzhu/gorm" 10 | ) 11 | 12 | var err error 13 | 14 | func main() { 15 | Config.DB, err = gorm.Open("mysql", Config.DbURL(Config.BuildDBConfig())) 16 | 17 | if err != nil { 18 | fmt.Println("Status:", err) 19 | } 20 | 21 | defer Config.DB.Close() 22 | Config.DB.AutoMigrate(&Models.Book{}) 23 | 24 | r := Routes.SetupRouter() 25 | //running 26 | r.Run() 27 | } 28 | -------------------------------------------------------------------------------- /GOLANG-MUX/.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, build with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | .idea 15 | -------------------------------------------------------------------------------- /GOLANG-MUX/datastore/datastore.go: -------------------------------------------------------------------------------- 1 | package datastore 2 | 3 | import "github.com/moficodes/bookdata/api/loader" 4 | 5 | type BookStore interface { 6 | Initialize() 7 | SearchAuthor(author string, ratingOver, ratingBelow float64, limit, skip int) *[]*loader.BookData 8 | SearchBook(bookName string, ratingOver, ratingBelow float64, limit, skip int) *[]*loader.BookData 9 | SearchISBN(isbn string) *loader.BookData 10 | CreateBook(book *loader.BookData) bool 11 | DeleteBook(isbn string) bool 12 | UpdateBook(isbn string, book *loader.BookData) bool 13 | } 14 | -------------------------------------------------------------------------------- /GOLANG-MUX/datastore/memory.go: -------------------------------------------------------------------------------- 1 | package datastore 2 | 3 | import ( 4 | "log" 5 | "os" 6 | "strings" 7 | 8 | "github.com/moficodes/bookdata/api/loader" 9 | ) 10 | 11 | type Books struct { 12 | Store *[]*loader.BookData `json:"store"` 13 | } 14 | 15 | func (b *Books) Initialize() { 16 | filename := "./assets/books.csv" 17 | file, err := os.Open(filename) 18 | if err != nil { 19 | log.Fatalln(err) 20 | } 21 | defer file.Close() 22 | b.Store = loader.LoadData(file) 23 | } 24 | 25 | func (b *Books) SearchAuthor(author string, ratingOver, ratingBelow float64, limit, skip int) *[]*loader.BookData { 26 | ret := Filter(b.Store, func(v *loader.BookData) bool { 27 | return strings.Contains(strings.ToLower(v.Authors), strings.ToLower(author)) && v.AverageRating > ratingOver && v.AverageRating < ratingBelow 28 | }) 29 | if limit == 0 || limit > len(*ret) { 30 | limit = len(*ret) 31 | } 32 | data := (*ret)[skip:limit] 33 | return &data 34 | } 35 | 36 | func (b *Books) SearchBook(bookName string, ratingOver, ratingBelow float64, limit, skip int) *[]*loader.BookData { 37 | ret := Filter(b.Store, func(v *loader.BookData) bool { 38 | return strings.Contains(strings.ToLower(v.Title), strings.ToLower(bookName)) && v.AverageRating > ratingOver && v.AverageRating < ratingBelow 39 | }) 40 | if limit == 0 || limit > len(*ret) { 41 | limit = len(*ret) 42 | } 43 | 44 | data := (*ret)[skip:limit] 45 | return &data 46 | } 47 | 48 | func (b *Books) SearchISBN(isbn string) *loader.BookData { 49 | ret := Filter(b.Store, func(v *loader.BookData) bool { 50 | return strings.ToLower(v.ISBN) == strings.ToLower(isbn) 51 | }) 52 | if len(*ret) > 0 { 53 | return (*ret)[0] 54 | } 55 | return nil 56 | } 57 | 58 | func (b *Books) CreateBook(book *loader.BookData) bool { 59 | *b.Store = append(*b.Store, book) 60 | return true 61 | } 62 | 63 | func (b *Books) DeleteBook(isbn string) bool { 64 | indexToDelete := -1 65 | for i, v := range *b.Store { 66 | if v.ISBN == isbn { 67 | indexToDelete = i 68 | break 69 | } 70 | } 71 | if indexToDelete >= 0 { 72 | (*b.Store)[indexToDelete], (*b.Store)[len(*b.Store)-1] = (*b.Store)[len(*b.Store)-1], (*b.Store)[indexToDelete] 73 | *b.Store = (*b.Store)[:len(*b.Store)-1] 74 | return true 75 | } 76 | return false 77 | } 78 | 79 | func (b *Books) UpdateBook(isbn string, book *loader.BookData) bool { 80 | for _, v := range *b.Store { 81 | if v.ISBN == isbn { 82 | v = book 83 | return true 84 | } 85 | } 86 | return false 87 | } 88 | 89 | func Filter(vs *[]*loader.BookData, f func(*loader.BookData) bool) *[]*loader.BookData { 90 | vsf := make([]*loader.BookData, 0) 91 | for _, v := range *vs { 92 | if f(v) { 93 | vsf = append(vsf, v) 94 | } 95 | } 96 | return &vsf 97 | } 98 | -------------------------------------------------------------------------------- /GOLANG-MUX/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/moficodes/bookdata/api 2 | 3 | go 1.12 4 | 5 | require github.com/gorilla/mux v1.7.3 6 | -------------------------------------------------------------------------------- /GOLANG-MUX/go.sum: -------------------------------------------------------------------------------- 1 | github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= 2 | github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= 3 | -------------------------------------------------------------------------------- /GOLANG-MUX/loader/loader.go: -------------------------------------------------------------------------------- 1 | package loader 2 | 3 | import ( 4 | "encoding/csv" 5 | "io" 6 | "log" 7 | "strconv" 8 | ) 9 | 10 | type BookData struct { 11 | BookID string `json:"book_id"` 12 | Title string `json:"title"` 13 | Authors string `json:"authors"` 14 | AverageRating float64 `json:"average_rating"` 15 | ISBN string `json:"isbn"` 16 | ISBN13 string `json:"isbn_13"` 17 | LanguageCode string `json:"language_code"` 18 | NumPages int `json:"num_pages"` 19 | Ratings int `json:"ratings"` 20 | Reviews int `json:"reviews"` 21 | } 22 | 23 | func LoadData(r io.Reader) *[]*BookData { 24 | reader := csv.NewReader(r) 25 | 26 | ret := make([]*BookData, 0, 0) 27 | 28 | for { 29 | row, err := reader.Read() 30 | if err == io.EOF { 31 | log.Println("End of File") 32 | break 33 | } else if err != nil { 34 | log.Println(err) 35 | break 36 | } 37 | averageRating, _ := strconv.ParseFloat(row[3], 64) 38 | numPages, _ := strconv.Atoi(row[7]) 39 | ratings, _ := strconv.Atoi(row[8]) 40 | reviews, _ := strconv.Atoi(row[9]) 41 | 42 | if err != nil { 43 | log.Println(err) 44 | } 45 | book := &BookData{ 46 | BookID: row[0], 47 | Title: row[1], 48 | Authors: row[2], 49 | AverageRating: averageRating, 50 | ISBN: row[4], 51 | ISBN13: row[5], 52 | LanguageCode: row[6], 53 | NumPages: numPages, 54 | Ratings: ratings, 55 | Reviews: reviews, 56 | } 57 | 58 | if err != nil { 59 | log.Fatalln(err) 60 | } 61 | 62 | ret = append(ret, book) 63 | } 64 | return &ret 65 | } 66 | -------------------------------------------------------------------------------- /GOLANG-MUX/manifest.yml: -------------------------------------------------------------------------------- 1 | --- 2 | applications: 3 | - name: 4 | random-route: true 5 | memory: 256M 6 | env: 7 | GOVERSION: go1.12 8 | GOPACKAGENAME: bookdata-api 9 | buildpack: https://github.com/cloudfoundry/go-buildpack.git 10 | -------------------------------------------------------------------------------- /GOLANG-MUX/server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/gorilla/mux" 6 | "github.com/moficodes/bookdata/api/datastore" 7 | "log" 8 | "net/http" 9 | "time" 10 | ) 11 | 12 | var ( 13 | books datastore.BookStore 14 | ) 15 | 16 | func timeTrack(start time.Time, name string) { 17 | elapsed := time.Since(start) 18 | log.Printf("%s took %s", name, elapsed) 19 | } 20 | 21 | func init() { 22 | defer timeTrack(time.Now(), "file load") 23 | books = &datastore.Books{} 24 | books.Initialize() 25 | } 26 | 27 | func main() { 28 | r := mux.NewRouter() 29 | log.Println("bookdata api") 30 | api := r.PathPrefix("/api/v1").Subrouter() 31 | api.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 32 | fmt.Fprintln(w, "api v1") 33 | }) 34 | api.HandleFunc("/books/authors/{author}", searchByAuthor).Methods(http.MethodGet) 35 | api.HandleFunc("/books/book-name/{bookName}", searchByBookName).Methods(http.MethodGet) 36 | api.HandleFunc("/book/isbn/{isbn}", searchByISBN).Methods(http.MethodGet) 37 | api.HandleFunc("/book/isbn/{isbn}", deleteByISBN).Methods(http.MethodDelete) 38 | api.HandleFunc("/book", createBook).Methods(http.MethodPost) 39 | log.Fatalln(http.ListenAndServe(":8080", r)) 40 | } 41 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/.env: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY=base64:j4cl5jgXaE9sF1FtNJb6f831GJBMDsXaHAHKG1bWPZ0= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | 9 | DB_CONNECTION=mysql 10 | DB_HOST=127.0.0.1 11 | DB_PORT=3306 12 | DB_DATABASE=laravel-backend-api 13 | DB_USERNAME=root 14 | DB_PASSWORD= 15 | 16 | BROADCAST_DRIVER=log 17 | CACHE_DRIVER=file 18 | QUEUE_CONNECTION=sync 19 | SESSION_DRIVER=file 20 | SESSION_LIFETIME=120 21 | 22 | REDIS_HOST=127.0.0.1 23 | REDIS_PASSWORD=null 24 | REDIS_PORT=6379 25 | 26 | MAIL_MAILER=smtp 27 | MAIL_HOST=smtp.mailtrap.io 28 | MAIL_PORT=2525 29 | MAIL_USERNAME=null 30 | MAIL_PASSWORD=null 31 | MAIL_ENCRYPTION=null 32 | MAIL_FROM_ADDRESS=null 33 | MAIL_FROM_NAME="${APP_NAME}" 34 | 35 | AWS_ACCESS_KEY_ID= 36 | AWS_SECRET_ACCESS_KEY= 37 | AWS_DEFAULT_REGION=us-east-1 38 | AWS_BUCKET= 39 | 40 | PUSHER_APP_ID= 41 | PUSHER_APP_KEY= 42 | PUSHER_APP_SECRET= 43 | PUSHER_APP_CLUSTER=mt1 44 | 45 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 46 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 47 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | 9 | DB_CONNECTION=mysql 10 | DB_HOST=127.0.0.1 11 | DB_PORT=3306 12 | DB_DATABASE=laravel 13 | DB_USERNAME=root 14 | DB_PASSWORD= 15 | 16 | BROADCAST_DRIVER=log 17 | CACHE_DRIVER=file 18 | QUEUE_CONNECTION=sync 19 | SESSION_DRIVER=file 20 | SESSION_LIFETIME=120 21 | 22 | REDIS_HOST=127.0.0.1 23 | REDIS_PASSWORD=null 24 | REDIS_PORT=6379 25 | 26 | MAIL_MAILER=smtp 27 | MAIL_HOST=smtp.mailtrap.io 28 | MAIL_PORT=2525 29 | MAIL_USERNAME=null 30 | MAIL_PASSWORD=null 31 | MAIL_ENCRYPTION=null 32 | MAIL_FROM_ADDRESS=null 33 | MAIL_FROM_NAME="${APP_NAME}" 34 | 35 | AWS_ACCESS_KEY_ID= 36 | AWS_SECRET_ACCESS_KEY= 37 | AWS_DEFAULT_REGION=us-east-1 38 | AWS_BUCKET= 39 | 40 | PUSHER_APP_ID= 41 | PUSHER_APP_KEY= 42 | PUSHER_APP_SECRET= 43 | PUSHER_APP_CLUSTER=mt1 44 | 45 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 46 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 47 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/.gitignore.txt: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.lock 5 | *.example 6 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire')->hourly(); 28 | } 29 | 30 | /** 31 | * Register the commands for the application. 32 | * 33 | * @return void 34 | */ 35 | protected function commands() 36 | { 37 | $this->load(__DIR__.'/Commands'); 38 | 39 | require base_path('routes/console.php'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | validate([ 14 | 'name' => 'required|max:55', 15 | 'email' => 'email|required|unique:users', 16 | 'password' => 'required|confirmed' 17 | ]); 18 | 19 | $validatedData['password'] = bcrypt($request->password); 20 | 21 | $user = User::create($validatedData); 22 | 23 | $accessToken = $user->createToken('authToken')->accessToken; 24 | 25 | return response([ 'user' => $user, 'access_token' => $accessToken]); 26 | } 27 | 28 | public function login(Request $request) 29 | { 30 | $loginData = $request->validate([ 31 | 'email' => 'email|required', 32 | 'password' => 'required' 33 | ]); 34 | 35 | if (!auth()->attempt($loginData)) { 36 | return response(['message' => 'Invalid Credentials']); 37 | } 38 | 39 | $accessToken = auth()->user()->createToken('authToken')->accessToken; 40 | 41 | return response(['user' => auth()->user(), 'access_token' => $accessToken]); 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/app/Http/Controllers/API/PropertyController.php: -------------------------------------------------------------------------------- 1 | PropertyResource::collection($propertys), 'message' => 'Retrieved successfully'], 200); 21 | } 22 | 23 | /** 24 | * Store a newly created resource in storage. 25 | * 26 | * @param \Illuminate\Http\Request $request 27 | * @return \Illuminate\Http\Response 28 | */ 29 | public function store(Request $request) 30 | { 31 | $data = $request->all(); 32 | 33 | $validator = Validator::make($data, [ 34 | 'property_name' => 'required|unique:properties|max:255', 35 | 'address' => 'required|max:255', 36 | 'city' => 'required|max:255', 37 | 'country' => 'required|max:255', 38 | 'type' => 'required|max:255', 39 | 'minimum_price' => 'required', 40 | 'maximum_price' => 'required', 41 | 'ready_to_sell' => 'required' 42 | ]); 43 | 44 | if($validator->fails()){ 45 | return response(['error' => $validator->errors(), 'Validation Error']); 46 | } 47 | 48 | $property = Property::create($data); 49 | 50 | return response([ 'property' => new PropertyResource($property), 'message' => 'Property Created Successfully'], 200); 51 | } 52 | 53 | /** 54 | * Display the specified resource. 55 | * 56 | * @param \App\Property $property 57 | * @return \Illuminate\Http\Response 58 | */ 59 | public function show(Property $property) 60 | { 61 | return response([ 'property' => new PropertyResource($property), 'message' => 'Retrieved Successfully'], 200); 62 | 63 | } 64 | 65 | /** 66 | * Update the specified resource in storage. 67 | * 68 | * @param \Illuminate\Http\Request $request 69 | * @param \App\Property $property 70 | * @return \Illuminate\Http\Response 71 | */ 72 | public function update(Request $request, Property $property) 73 | { 74 | 75 | $property->update($request->all()); 76 | 77 | return response([ 'property' => new PropertyResource($property), 'message' => 'Property Updated Successfully'], 200); 78 | } 79 | 80 | /** 81 | * Remove the specified resource from storage. 82 | * 83 | * @param \App\Property $property 84 | * @return \Illuminate\Http\Response 85 | * @throws \Exception 86 | */ 87 | public function destroy(Property $property) 88 | { 89 | $property->delete(); 90 | 91 | return response(['message' => 'Property Deleted Successfully']); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | [ 33 | \App\Http\Middleware\EncryptCookies::class, 34 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 35 | \Illuminate\Session\Middleware\StartSession::class, 36 | // \Illuminate\Session\Middleware\AuthenticateSession::class, 37 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 38 | \App\Http\Middleware\VerifyCsrfToken::class, 39 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 40 | ], 41 | 42 | 'api' => [ 43 | 'throttle:60,1', 44 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 45 | ], 46 | ]; 47 | 48 | /** 49 | * The application's route middleware. 50 | * 51 | * These middleware may be assigned to groups or used individually. 52 | * 53 | * @var array 54 | */ 55 | protected $routeMiddleware = [ 56 | 'auth' => \App\Http\Middleware\Authenticate::class, 57 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 58 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 59 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 60 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 61 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 62 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 63 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 64 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 65 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 66 | ]; 67 | } 68 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 18 | return route('login'); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/app/Http/Middleware/CheckForMaintenanceMode.php: -------------------------------------------------------------------------------- 1 | check()) { 22 | return redirect(RouteServiceProvider::HOME); 23 | } 24 | 25 | return $next($request); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | allSubdomainsOfApplicationUrl(), 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/app/Http/Middleware/TrustProxies.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', // uncomment this line 18 | ]; 19 | 20 | /** 21 | * Register any authentication / authorization services. 22 | * 23 | * @return void 24 | */ 25 | public function boot() 26 | { 27 | $this->registerPolicies(); 28 | 29 | Passport::routes(); // Add this 30 | } 31 | } -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | * 26 | * @return void 27 | */ 28 | public function boot() 29 | { 30 | parent::boot(); 31 | 32 | // 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | mapApiRoutes(); 46 | 47 | $this->mapWebRoutes(); 48 | 49 | // 50 | } 51 | 52 | /** 53 | * Define the "web" routes for the application. 54 | * 55 | * These routes all receive session state, CSRF protection, etc. 56 | * 57 | * @return void 58 | */ 59 | protected function mapWebRoutes() 60 | { 61 | Route::middleware('web') 62 | ->namespace($this->namespace) 63 | ->group(base_path('routes/web.php')); 64 | } 65 | 66 | /** 67 | * Define the "api" routes for the application. 68 | * 69 | * These routes are typically stateless. 70 | * 71 | * @return void 72 | */ 73 | protected function mapApiRoutes() 74 | { 75 | Route::prefix('api') 76 | ->middleware('api') 77 | ->namespace($this->namespace) 78 | ->group(base_path('routes/api.php')); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/app/User.php: -------------------------------------------------------------------------------- 1 | 'datetime', 39 | ]; 40 | } 41 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The Laravel Framework.", 5 | "keywords": [ 6 | "framework", 7 | "laravel" 8 | ], 9 | "license": "MIT", 10 | "require": { 11 | "php": "^7.2.5|^8.0", 12 | "fideloper/proxy": "^4.4", 13 | "fruitcake/laravel-cors": "^2.0", 14 | "guzzlehttp/guzzle": "^6.3.1|^7.0.1", 15 | "laravel/framework": "^7.29", 16 | "laravel/passport": "^9.4", 17 | "laravel/tinker": "^2.5" 18 | }, 19 | "require-dev": { 20 | "facade/ignition": "^2.0", 21 | "fakerphp/faker": "^1.9.1", 22 | "mockery/mockery": "^1.3.1", 23 | "nunomaduro/collision": "^4.3", 24 | "phpunit/phpunit": "^8.5.8|^9.3.3" 25 | }, 26 | "config": { 27 | "optimize-autoloader": true, 28 | "preferred-install": "dist", 29 | "sort-packages": true 30 | }, 31 | "extra": { 32 | "laravel": { 33 | "dont-discover": [] 34 | } 35 | }, 36 | "autoload": { 37 | "psr-4": { 38 | "App\\": "app/" 39 | }, 40 | "classmap": [ 41 | "database/seeds", 42 | "database/factories" 43 | ] 44 | }, 45 | "autoload-dev": { 46 | "psr-4": { 47 | "Tests\\": "tests/" 48 | } 49 | }, 50 | "minimum-stability": "dev", 51 | "prefer-stable": true, 52 | "scripts": { 53 | "post-autoload-dump": [ 54 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 55 | "@php artisan package:discover --ansi" 56 | ], 57 | "post-root-package-install": [ 58 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 59 | ], 60 | "post-create-project-cmd": [ 61 | "@php artisan key:generate --ansi" 62 | ] 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'web', 18 | 'passwords' => 'users', 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | here which uses session storage and the Eloquent user provider. 29 | | 30 | | All authentication drivers have a user provider. This defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | mechanisms used by this application to persist your user's data. 33 | | 34 | | Supported: "session", "token" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | 44 | 'api' => [ 45 | 'driver' => 'passport', 46 | 'provider' => 'users', 47 | 'hash' => false, 48 | ], 49 | ], 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | User Providers 54 | |-------------------------------------------------------------------------- 55 | | 56 | | All authentication drivers have a user provider. This defines how the 57 | | users are actually retrieved out of your database or other storage 58 | | mechanisms used by this application to persist your user's data. 59 | | 60 | | If you have multiple user tables or models you may configure multiple 61 | | sources which represent each model / table. These sources may then 62 | | be assigned to any extra authentication guards you have defined. 63 | | 64 | | Supported: "database", "eloquent" 65 | | 66 | */ 67 | 68 | 'providers' => [ 69 | 'users' => [ 70 | 'driver' => 'eloquent', 71 | 'model' => App\User::class, 72 | ], 73 | 74 | // 'users' => [ 75 | // 'driver' => 'database', 76 | // 'table' => 'users', 77 | // ], 78 | ], 79 | 80 | /* 81 | |-------------------------------------------------------------------------- 82 | | Resetting Passwords 83 | |-------------------------------------------------------------------------- 84 | | 85 | | You may specify multiple password reset configurations if you have more 86 | | than one user table or model in the application and you want to have 87 | | separate password reset settings based on the specific user types. 88 | | 89 | | The expire time is the number of minutes that the reset token should be 90 | | considered valid. This security feature keeps tokens short-lived so 91 | | they have less time to be guessed. You may change this as needed. 92 | | 93 | */ 94 | 95 | 'passwords' => [ 96 | 'users' => [ 97 | 'provider' => 'users', 98 | 'table' => 'password_resets', 99 | 'expire' => 60, 100 | 'throttle' => 60, 101 | ], 102 | ], 103 | 104 | /* 105 | |-------------------------------------------------------------------------- 106 | | Password Confirmation Timeout 107 | |-------------------------------------------------------------------------- 108 | | 109 | | Here you may define the amount of seconds before a password confirmation 110 | | times out and the user is prompted to re-enter their password via the 111 | | confirmation screen. By default, the timeout lasts for three hours. 112 | | 113 | */ 114 | 115 | 'password_timeout' => 10800, 116 | 117 | ]; 118 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'cluster' => env('PUSHER_APP_CLUSTER'), 40 | 'useTLS' => true, 41 | ], 42 | ], 43 | 44 | 'redis' => [ 45 | 'driver' => 'redis', 46 | 'connection' => 'default', 47 | ], 48 | 49 | 'log' => [ 50 | 'driver' => 'log', 51 | ], 52 | 53 | 'null' => [ 54 | 'driver' => 'null', 55 | ], 56 | 57 | ], 58 | 59 | ]; 60 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Cache Stores 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Here you may define all of the cache "stores" for your application as 29 | | well as their drivers. You may even define multiple stores for the 30 | | same cache driver to group types of items stored in your caches. 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'apc' => [ 37 | 'driver' => 'apc', 38 | ], 39 | 40 | 'array' => [ 41 | 'driver' => 'array', 42 | 'serialize' => false, 43 | ], 44 | 45 | 'database' => [ 46 | 'driver' => 'database', 47 | 'table' => 'cache', 48 | 'connection' => null, 49 | ], 50 | 51 | 'file' => [ 52 | 'driver' => 'file', 53 | 'path' => storage_path('framework/cache/data'), 54 | ], 55 | 56 | 'memcached' => [ 57 | 'driver' => 'memcached', 58 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 59 | 'sasl' => [ 60 | env('MEMCACHED_USERNAME'), 61 | env('MEMCACHED_PASSWORD'), 62 | ], 63 | 'options' => [ 64 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 65 | ], 66 | 'servers' => [ 67 | [ 68 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 69 | 'port' => env('MEMCACHED_PORT', 11211), 70 | 'weight' => 100, 71 | ], 72 | ], 73 | ], 74 | 75 | 'redis' => [ 76 | 'driver' => 'redis', 77 | 'connection' => 'cache', 78 | ], 79 | 80 | 'dynamodb' => [ 81 | 'driver' => 'dynamodb', 82 | 'key' => env('AWS_ACCESS_KEY_ID'), 83 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 84 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 85 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 86 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 87 | ], 88 | 89 | ], 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Cache Key Prefix 94 | |-------------------------------------------------------------------------- 95 | | 96 | | When utilizing a RAM based store such as APC or Memcached, there might 97 | | be other applications utilizing the same cache. So, we'll specify a 98 | | value to get prefixed to all our keys so we can avoid collisions. 99 | | 100 | */ 101 | 102 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), 103 | 104 | ]; 105 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/config/cors.php: -------------------------------------------------------------------------------- 1 | ['api/*'], 19 | 20 | 'allowed_methods' => ['*'], 21 | 22 | 'allowed_origins' => ['*'], 23 | 24 | 'allowed_origins_patterns' => [], 25 | 26 | 'allowed_headers' => ['*'], 27 | 28 | 'exposed_headers' => [], 29 | 30 | 'max_age' => 0, 31 | 32 | 'supports_credentials' => false, 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DRIVER', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default Cloud Filesystem Disk 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Many applications store files both locally and in the cloud. For this 24 | | reason, you may specify a default "cloud" driver here. This driver 25 | | will be bound as the Cloud disk implementation in the container. 26 | | 27 | */ 28 | 29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Filesystem Disks 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here you may configure as many filesystem "disks" as you wish, and you 37 | | may even configure multiple disks of the same driver. Defaults have 38 | | been setup for each driver as an example of the required options. 39 | | 40 | | Supported Drivers: "local", "ftp", "sftp", "s3" 41 | | 42 | */ 43 | 44 | 'disks' => [ 45 | 46 | 'local' => [ 47 | 'driver' => 'local', 48 | 'root' => storage_path('app'), 49 | ], 50 | 51 | 'public' => [ 52 | 'driver' => 'local', 53 | 'root' => storage_path('app/public'), 54 | 'url' => env('APP_URL').'/storage', 55 | 'visibility' => 'public', 56 | ], 57 | 58 | 's3' => [ 59 | 'driver' => 's3', 60 | 'key' => env('AWS_ACCESS_KEY_ID'), 61 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 62 | 'region' => env('AWS_DEFAULT_REGION'), 63 | 'bucket' => env('AWS_BUCKET'), 64 | 'url' => env('AWS_URL'), 65 | 'endpoint' => env('AWS_ENDPOINT'), 66 | ], 67 | 68 | ], 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Symbolic Links 73 | |-------------------------------------------------------------------------- 74 | | 75 | | Here you may configure the symbolic links that will be created when the 76 | | `storage:link` Artisan command is executed. The array keys should be 77 | | the locations of the links and the values should be their targets. 78 | | 79 | */ 80 | 81 | 'links' => [ 82 | public_path('storage') => storage_path('app/public'), 83 | ], 84 | 85 | ]; 86 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 10), 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Argon Options 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may specify the configuration options that should be used when 41 | | passwords are hashed using the Argon algorithm. These will allow you 42 | | to control the amount of time it takes to hash the given password. 43 | | 44 | */ 45 | 46 | 'argon' => [ 47 | 'memory' => 1024, 48 | 'threads' => 2, 49 | 'time' => 2, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Log Channels 25 | |-------------------------------------------------------------------------- 26 | | 27 | | Here you may configure the log channels for your application. Out of 28 | | the box, Laravel uses the Monolog PHP logging library. This gives 29 | | you a variety of powerful log handlers / formatters to utilize. 30 | | 31 | | Available Drivers: "single", "daily", "slack", "syslog", 32 | | "errorlog", "monolog", 33 | | "custom", "stack" 34 | | 35 | */ 36 | 37 | 'channels' => [ 38 | 'stack' => [ 39 | 'driver' => 'stack', 40 | 'channels' => ['single'], 41 | 'ignore_exceptions' => false, 42 | ], 43 | 44 | 'single' => [ 45 | 'driver' => 'single', 46 | 'path' => storage_path('logs/laravel.log'), 47 | 'level' => 'debug', 48 | ], 49 | 50 | 'daily' => [ 51 | 'driver' => 'daily', 52 | 'path' => storage_path('logs/laravel.log'), 53 | 'level' => 'debug', 54 | 'days' => 14, 55 | ], 56 | 57 | 'slack' => [ 58 | 'driver' => 'slack', 59 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 60 | 'username' => 'Laravel Log', 61 | 'emoji' => ':boom:', 62 | 'level' => 'critical', 63 | ], 64 | 65 | 'papertrail' => [ 66 | 'driver' => 'monolog', 67 | 'level' => 'debug', 68 | 'handler' => SyslogUdpHandler::class, 69 | 'handler_with' => [ 70 | 'host' => env('PAPERTRAIL_URL'), 71 | 'port' => env('PAPERTRAIL_PORT'), 72 | ], 73 | ], 74 | 75 | 'stderr' => [ 76 | 'driver' => 'monolog', 77 | 'handler' => StreamHandler::class, 78 | 'formatter' => env('LOG_STDERR_FORMATTER'), 79 | 'with' => [ 80 | 'stream' => 'php://stderr', 81 | ], 82 | ], 83 | 84 | 'syslog' => [ 85 | 'driver' => 'syslog', 86 | 'level' => 'debug', 87 | ], 88 | 89 | 'errorlog' => [ 90 | 'driver' => 'errorlog', 91 | 'level' => 'debug', 92 | ], 93 | 94 | 'null' => [ 95 | 'driver' => 'monolog', 96 | 'handler' => NullHandler::class, 97 | ], 98 | 99 | 'emergency' => [ 100 | 'path' => storage_path('logs/laravel.log'), 101 | ], 102 | ], 103 | 104 | ]; 105 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_MAILER', 'smtp'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Mailer Configurations 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure all of the mailers used by your application plus 24 | | their respective settings. Several examples have been configured for 25 | | you and you are free to add your own as your application requires. 26 | | 27 | | Laravel supports a variety of mail "transport" drivers to be used while 28 | | sending an e-mail. You will specify which one you are using for your 29 | | mailers below. You are free to add additional mailers as required. 30 | | 31 | | Supported: "smtp", "sendmail", "mailgun", "ses", 32 | | "postmark", "log", "array" 33 | | 34 | */ 35 | 36 | 'mailers' => [ 37 | 'smtp' => [ 38 | 'transport' => 'smtp', 39 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 40 | 'port' => env('MAIL_PORT', 587), 41 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 42 | 'username' => env('MAIL_USERNAME'), 43 | 'password' => env('MAIL_PASSWORD'), 44 | 'timeout' => null, 45 | 'auth_mode' => null, 46 | ], 47 | 48 | 'ses' => [ 49 | 'transport' => 'ses', 50 | ], 51 | 52 | 'mailgun' => [ 53 | 'transport' => 'mailgun', 54 | ], 55 | 56 | 'postmark' => [ 57 | 'transport' => 'postmark', 58 | ], 59 | 60 | 'sendmail' => [ 61 | 'transport' => 'sendmail', 62 | 'path' => '/usr/sbin/sendmail -bs', 63 | ], 64 | 65 | 'log' => [ 66 | 'transport' => 'log', 67 | 'channel' => env('MAIL_LOG_CHANNEL'), 68 | ], 69 | 70 | 'array' => [ 71 | 'transport' => 'array', 72 | ], 73 | ], 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Global "From" Address 78 | |-------------------------------------------------------------------------- 79 | | 80 | | You may wish for all e-mails sent by your application to be sent from 81 | | the same address. Here, you may specify a name and address that is 82 | | used globally for all e-mails that are sent by your application. 83 | | 84 | */ 85 | 86 | 'from' => [ 87 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 88 | 'name' => env('MAIL_FROM_NAME', 'Example'), 89 | ], 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Markdown Mail Settings 94 | |-------------------------------------------------------------------------- 95 | | 96 | | If you are using Markdown based email rendering, you may configure your 97 | | theme and component paths here, allowing you to customize the design 98 | | of the emails. Or, you may simply stick with the Laravel defaults! 99 | | 100 | */ 101 | 102 | 'markdown' => [ 103 | 'theme' => 'default', 104 | 105 | 'paths' => [ 106 | resource_path('views/vendor/mail'), 107 | ], 108 | ], 109 | 110 | ]; 111 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'sync'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection information for each server that 24 | | is used by your application. A default configuration has been added 25 | | for each back-end shipped with Laravel. You are free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'table' => 'jobs', 40 | 'queue' => 'default', 41 | 'retry_after' => 90, 42 | ], 43 | 44 | 'beanstalkd' => [ 45 | 'driver' => 'beanstalkd', 46 | 'host' => 'localhost', 47 | 'queue' => 'default', 48 | 'retry_after' => 90, 49 | 'block_for' => 0, 50 | ], 51 | 52 | 'sqs' => [ 53 | 'driver' => 'sqs', 54 | 'key' => env('AWS_ACCESS_KEY_ID'), 55 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 56 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 57 | 'queue' => env('SQS_QUEUE', 'your-queue-name'), 58 | 'suffix' => env('SQS_SUFFIX'), 59 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 60 | ], 61 | 62 | 'redis' => [ 63 | 'driver' => 'redis', 64 | 'connection' => 'default', 65 | 'queue' => env('REDIS_QUEUE', 'default'), 66 | 'retry_after' => 90, 67 | 'block_for' => null, 68 | ], 69 | 70 | ], 71 | 72 | /* 73 | |-------------------------------------------------------------------------- 74 | | Failed Queue Jobs 75 | |-------------------------------------------------------------------------- 76 | | 77 | | These options configure the behavior of failed queue job logging so you 78 | | can control which database and table are used to store the jobs that 79 | | have failed. You may change them to any database / table you wish. 80 | | 81 | */ 82 | 83 | 'failed' => [ 84 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database'), 85 | 'database' => env('DB_CONNECTION', 'mysql'), 86 | 'table' => 'failed_jobs', 87 | ], 88 | 89 | ]; 90 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | ], 22 | 23 | 'postmark' => [ 24 | 'token' => env('POSTMARK_TOKEN'), 25 | ], 26 | 27 | 'ses' => [ 28 | 'key' => env('AWS_ACCESS_KEY_ID'), 29 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 30 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 31 | ], 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => env( 32 | 'VIEW_COMPILED_PATH', 33 | realpath(storage_path('framework/views')) 34 | ), 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | *.sqlite-journal 3 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | define(User::class, function (Faker $faker) { 21 | return [ 22 | 'name' => $faker->name, 23 | 'email' => $faker->unique()->safeEmail, 24 | 'email_verified_at' => now(), 25 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 26 | 'remember_token' => Str::random(10), 27 | ]; 28 | }); 29 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->timestamp('email_verified_at')->nullable(); 21 | $table->string('password'); 22 | $table->rememberToken(); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('users'); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->text('connection'); 19 | $table->text('queue'); 20 | $table->longText('payload'); 21 | $table->longText('exception'); 22 | $table->timestamp('failed_at')->useCurrent(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('failed_jobs'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/database/migrations/2020_12_27_061132_create_properties_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('property_name'); 19 | $table->string('address'); 20 | $table->string('city'); 21 | $table->string('country'); 22 | $table->string('type'); 23 | $table->float('minimum_price'); 24 | $table->float('maximum_price'); 25 | $table->integer('ready_to_sell'); 26 | $table->timestamps(); 27 | }); 28 | } 29 | /** 30 | * Reverse the migrations. 31 | * 32 | * @return void 33 | */ 34 | public function down() 35 | { 36 | Schema::dropIfExists('property'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(UserSeeder::class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "npm run development", 5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js", 6 | "watch": "npm run development -- --watch", 7 | "watch-poll": "npm run watch -- --watch-poll", 8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js", 9 | "prod": "npm run production", 10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --config=node_modules/laravel-mix/setup/webpack.config.js" 11 | }, 12 | "devDependencies": { 13 | "axios": "^0.19", 14 | "cross-env": "^7.0", 15 | "laravel-mix": "^5.0.1", 16 | "lodash": "^4.17.19", 17 | "resolve-url-loader": "^3.1.0", 18 | "sass": "^1.15.2", 19 | "sass-loader": "^8.0.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Send Requests To Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/LARAVEL-PASSPORT/public/favicon.ico -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/public/index.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | define('LARAVEL_START', microtime(true)); 11 | 12 | /* 13 | |-------------------------------------------------------------------------- 14 | | Register The Auto Loader 15 | |-------------------------------------------------------------------------- 16 | | 17 | | Composer provides a convenient, automatically generated class loader for 18 | | our application. We just need to utilize it! We'll simply require it 19 | | into the script here so that we don't have to worry about manual 20 | | loading any of our classes later on. It feels great to relax. 21 | | 22 | */ 23 | 24 | require __DIR__.'/../vendor/autoload.php'; 25 | 26 | /* 27 | |-------------------------------------------------------------------------- 28 | | Turn On The Lights 29 | |-------------------------------------------------------------------------- 30 | | 31 | | We need to illuminate PHP development, so let us turn on the lights. 32 | | This bootstraps the framework and gets it ready for use, then it 33 | | will load up this application so that we can run it and send 34 | | the responses back to the browser and delight our users. 35 | | 36 | */ 37 | 38 | $app = require_once __DIR__.'/../bootstrap/app.php'; 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Run The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once we have the application, we can handle the incoming request 46 | | through the kernel, and send the associated response back to 47 | | the client's browser allowing them to enjoy the creative 48 | | and wonderful application we have prepared for them. 49 | | 50 | */ 51 | 52 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); 53 | 54 | $response = $kernel->handle( 55 | $request = Illuminate\Http\Request::capture() 56 | ); 57 | 58 | $response->send(); 59 | 60 | $kernel->terminate($request, $response); 61 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/public/web.config: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/resources/js/app.js: -------------------------------------------------------------------------------- 1 | require('./bootstrap'); 2 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | window._ = require('lodash'); 2 | 3 | /** 4 | * We'll load the axios HTTP library which allows us to easily issue requests 5 | * to our Laravel back-end. This library automatically handles sending the 6 | * CSRF token as a header based on the value of the "XSRF" token cookie. 7 | */ 8 | 9 | window.axios = require('axios'); 10 | 11 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 12 | 13 | /** 14 | * Echo exposes an expressive API for subscribing to channels and listening 15 | * for events that are broadcast by Laravel. Echo and event broadcasting 16 | * allows your team to easily build robust real-time web applications. 17 | */ 18 | 19 | // import Echo from 'laravel-echo'; 20 | 21 | // window.Pusher = require('pusher-js'); 22 | 23 | // window.Echo = new Echo({ 24 | // broadcaster: 'pusher', 25 | // key: process.env.MIX_PUSHER_APP_KEY, 26 | // cluster: process.env.MIX_PUSHER_APP_CLUSTER, 27 | // forceTLS: true 28 | // }); 29 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Your password has been reset!', 17 | 'sent' => 'We have emailed your password reset link!', 18 | 'throttled' => 'Please wait before retrying.', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that email address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/resources/sass/app.scss: -------------------------------------------------------------------------------- 1 | // 2 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/resources/views/welcome.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Laravel 8 | 9 | 10 | 11 | 12 | 13 | 65 | 66 | 67 |
68 | @if (Route::has('login')) 69 | 80 | @endif 81 | 82 |
83 |
84 | Laravel 85 |
86 | 87 | 97 |
98 |
99 | 100 | 101 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/routes/api.php: -------------------------------------------------------------------------------- 1 | middleware('auth:api'); -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 18 | }); 19 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 19 | })->describe('Display an inspiring quote'); 20 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/routes/web.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | schedule-* 4 | compiled.php 5 | services.json 6 | events.scanned.php 7 | routes.scanned.php 8 | down 9 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/storage/oauth-private.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIJKAIBAAKCAgEArKUdDc7fkpXZ92sMQDoBY2gmhE4XrTRZ0uVWoSmNIevO/2pk 3 | i3oOtYNDANM8hcNLYep7GTMZu44VC7lA6vblnbG5V8EXBPHZR7CAv2wc29jM04g6 4 | gIgRtZaHmHUUeP9WjkNdDc1/gLyVku33YX5g08GsQI1aMBP+p0i7K4/CoI+R+pLo 5 | fcNEjTiz9u5OkqtMjOVQOz5GEhZ+BKPsUJe6+SYbEv4yVwv1oXrP2OPYcdg7WUqR 6 | KXHRXH2biTPS28viL42C5APADkBepW6dQIOBlw1E0wmzMIv42vyVjOcb2+UA7xBJ 7 | NgSoYgVOV8kmZpMBYOC0mqkzWTzNqNO7iganhqlnOShYwH9o5s37pMB6d6wsY94p 8 | mV4LkVidUzr/JBzWdeLV0u0etUYNcfeefqVm/NueeV/p9yz02qvPSQ97K2ECiRji 9 | oW1T3qXUKqriB6EeBy7pt5Ks/HweD7JiXIaZLxbcS2/V14N6tUCNvV7sySdV2ynX 10 | dI0mkcXiUqrlQKsaBGykw+HBBOj9oDs2Vmn0zew1U8o+9c8M63qmy//ebEl3i6db 11 | SotSbHnxFir0PjMJCgQ68qZP6XHI6H1wNkhIwgUOF/MXWxYY792MX6EDKPzisj6O 12 | pKq68jpEPMejiNdWSu8NuQ+d3kHwL0ILOoyViDemHQEFBQ4rn169Mqjk0m8CAwEA 13 | AQKCAgAsaXE26x/SWqAuqKgHIaTXyKQX5urqUIxG115YqRK4RiwCwoDI7IY6JWEo 14 | Ji7sjhenQaWXDvEwsVUypd5QU2EwFtcB/xcH25s0ePA1zf8Cgxv10paSF+7OUsHg 15 | 80Vn9u9yO1wFv/ZrzJeBq5u2xcbs0maYWIR517rrl6cmhp3fpe88kWwjZgcNeSe6 16 | fwVRb6WKnTbtdpCZ+JVEZlLVTKL5ktbmJOQYRmhSuQAc4Ef+yUxDJQ6ApdngvCM1 17 | wVId3q3546JnO5u9TsvKLNFhFjNRA0XQMC+bbnZ/BvkFvTIKeDesR/k9Xyddx9Wm 18 | eYVaX7i8DjIHkz01WJHjO0yELkAL1NuRNdm3EvaTmCID01aySN7MVV/yx6IC0Zo6 19 | kWgHGmk4IOPO1Gc84Iy+MxsydEFJw6oUiYEGi0EOFT8UYD6lfkjkxoHWslvxm2kx 20 | r08Y4EzZyPISXU6LU3PgDvaoA8tcvzxK/L15FafLqsk8ZyxVnNo/O8WewejlZCr1 21 | 9gWkuQUrC8i5bc0KuJqqEk1zXi3dCbHp9TOKItq+cg5kkB0Omkzu+3tWcqjoPwze 22 | 6IkqcZrZf5r7T/5A/I5A/sh/KgG0MaB3ElLkDNPXYzMSDAzn4CeUWBfexzVuI/46 23 | XdfcbA1UWMob7N7Gs9ZPBUmN2Kn6aYod14iM276qNv93ql5sqQKCAQEA3WIIJLok 24 | 5Jt4KdflJ7E0UHffiu/qr/RdYAVLrgBGHrgzXCjXuf49VQFdjsI6JTJz0yzbsxb2 25 | 3Q9xA0zr20M/COLYIjUSJWL3Dv4VYNlyHXx4MKQQzuQ86aOay5wYeK8Wo8rZB7zw 26 | upZ1upbgmFQGDupdKdSU1JFuMlW5uTgqbRtsnE9EGWG6GcwH8oMBCc9Fd7nDf8hG 27 | O+NgCZrCXwjT3suvcpBhdunVulAQwrcdp3OdfJMTwa7FCFVEDQYa6wHdhQa+09Q6 28 | ejielK+iX3CAZ07MsZDrroAoCXNRmnPZRuQbKV+5NvxWd94EWHbDOyZb9R+CLepY 29 | QicUR7zY96s+TQKCAQEAx6QZWZTn6bz6hxT5akCLkYDmmSl+N3SJc7YT2yCZmALM 30 | MISvZObG/yjb0Xo56P/MXOtF8Z4sNP6s0N4tSoZH1WCHgMoO85hY+9FnoOitk3Uv 31 | +FZGJ054kXkc1Q7lGN9CsxoJwLGC1i4aGWUKSyIkVfdERGu7XFM/aLkKkmmzZPm3 32 | u6AdJlAwzZ+0XHKuh+1cfJOurIENSgyooTcu7fasD3LC20YHlgFRlSPmNiSiaKth 33 | Ki+rV1d/FUODcSqPN2xdlBPpF5RMqge0G0FlNojGPT2zS0xtXSqBpYkqSIfUUA0c 34 | WVwcvj6QBn2xcL77PXQq4qgFSlQ8B8bslMgYjVeJqwKCAQBg685M5gHI5BfTmeWF 35 | XxtcL1764NaKeh13MFpVr2EDiflSW782eow3bwWavoXeSxxSU81Ltr4VQfFkVITd 36 | 1a7/IPEm6L0tCQrI0YxiflBrgFbOVMXXDi1szGe0xH4iN+VdiC1EKf/qcHzSV8O0 37 | bPTKCukGqz8NYS4xcz6ATIqmgd8m/7z8r8BeEulXzurhdJEhPX7Nrsyw43bkPZDj 38 | MmYvoFULfxJskSs1CmCMHscozIEiTPHVVcKFR28nlIisYoCtAKsC6mM/pxImXk5k 39 | IkjU8bbD9oJ4PztIB+iuChIR60PI9VONMyRYDicw463Nc5nG0yiXGYXSUHGchp0m 40 | sR3xAoIBABRWLw7lEErLKWohRNcCBDWqP9NSWr0jbe0Pmy4zP/IwNsSqf4Nzzsmn 41 | S90m6kdF53d/r/xQ9IfheZE9ULfKvf6KesMv0h4WYtokFr5ZdXUT9vMBNtxCLh4D 42 | jGBXyBakh5LfECdE7eMLhzUXCdllfPYU3itqHgflowvz7ZPEmLWsin7ebJm+iXoo 43 | zqKsPAM0trsqAB0qeEQWzga+LFWpTxWzxw23MIajU8Axi/3v9WtcKeW2PWoES7nK 44 | ytT4VOZ8b3vqG1B/lt+rMTmli73maOtMIbuF6Y4YCmTmeBwzWfldnImtzG/Ex78h 45 | hrXJfqZf8w5rtz4/Hm5cYTU2vOmJBUkCggEBALVQNWGX9PuLuCRCg+TY90NHRe8R 46 | Czf410XV9aYJDlpQGxPYRdIkTfqTWQTIkEWalyAgNPn3V1srS4lTovBuzffts1cu 47 | zPHU5nKtAtfD4q8LzYrFKN/km6nTvwNmGM3FE+xNffy7cLMZpSFIFDr+rlVVqUYj 48 | R9nkwjc47/wSJRZjbiQAHiTpsfWyFXCYOl2aPuC6peuM0yqDJ9NopOEU96ex63A/ 49 | 4qnV74jkLitmoMeFWXeINBKvDsk2L+Kg+Bo2DkBWlxO2Vom8ejwhu0LOf3VsoIkJ 50 | +Nbnzwk1K+WiY8jDePqlIsiHed6cY8TUZmF7Litmj7oQ9Uv4UtqDhXtwEjU= 51 | -----END RSA PRIVATE KEY----- -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/storage/oauth-public.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEArKUdDc7fkpXZ92sMQDoB 3 | Y2gmhE4XrTRZ0uVWoSmNIevO/2pki3oOtYNDANM8hcNLYep7GTMZu44VC7lA6vbl 4 | nbG5V8EXBPHZR7CAv2wc29jM04g6gIgRtZaHmHUUeP9WjkNdDc1/gLyVku33YX5g 5 | 08GsQI1aMBP+p0i7K4/CoI+R+pLofcNEjTiz9u5OkqtMjOVQOz5GEhZ+BKPsUJe6 6 | +SYbEv4yVwv1oXrP2OPYcdg7WUqRKXHRXH2biTPS28viL42C5APADkBepW6dQIOB 7 | lw1E0wmzMIv42vyVjOcb2+UA7xBJNgSoYgVOV8kmZpMBYOC0mqkzWTzNqNO7igan 8 | hqlnOShYwH9o5s37pMB6d6wsY94pmV4LkVidUzr/JBzWdeLV0u0etUYNcfeefqVm 9 | /NueeV/p9yz02qvPSQ97K2ECiRjioW1T3qXUKqriB6EeBy7pt5Ks/HweD7JiXIaZ 10 | LxbcS2/V14N6tUCNvV7sySdV2ynXdI0mkcXiUqrlQKsaBGykw+HBBOj9oDs2Vmn0 11 | zew1U8o+9c8M63qmy//ebEl3i6dbSotSbHnxFir0PjMJCgQ68qZP6XHI6H1wNkhI 12 | wgUOF/MXWxYY792MX6EDKPzisj6OpKq68jpEPMejiNdWSu8NuQ+d3kHwL0ILOoyV 13 | iDemHQEFBQ4rn169Mqjk0m8CAwEAAQ== 14 | -----END PUBLIC KEY----- -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 18 | 19 | $response->assertStatus(200); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/tests/TestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LARAVEL-PASSPORT/webpack.mix.js: -------------------------------------------------------------------------------- 1 | const mix = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel application. By default, we are compiling the Sass 10 | | file for the application as well as bundling up all the JS files. 11 | | 12 | */ 13 | 14 | mix.js('resources/js/app.js', 'public/js') 15 | .sass('resources/sass/app.scss', 'public/css'); 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Sapan Kumar Mohanty 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-MYSQL/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json -------------------------------------------------------------------------------- /NODEJS-EXPRESS-MYSQL/app/config/db.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | HOST: "localhost", 3 | USER: "root", 4 | PASSWORD: "", 5 | DB: "nodejs" 6 | }; 7 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-MYSQL/app/controllers/property.controller.js: -------------------------------------------------------------------------------- 1 | const Property = require("../models/property.model.js"); 2 | 3 | // Create and Save a new Property 4 | exports.create = (req, res) => { 5 | // Validate request 6 | if (!req.body) { 7 | res.status(400).send({ 8 | message: "Content can not be empty!" 9 | }); 10 | } 11 | 12 | // Create a Property 13 | const property = new Property({ 14 | property_name: req.body.property_name, 15 | address: req.body.address, 16 | city: req.body.city, 17 | country: req.body.country, 18 | type: req.body.type, 19 | minimum_price: req.body.minimum_price, 20 | maximum_price: req.body.maximum_price, 21 | ready_to_sell:req.body.ready_to_sell 22 | }); 23 | 24 | console.log(req.body); 25 | 26 | // Save Property in the database 27 | Property.create(property, (err, data) => { 28 | if (err) 29 | res.status(500).send({ 30 | message: 31 | err.message || "Some error occurred while creating the Property." 32 | }); 33 | else res.send(data); 34 | }); 35 | }; 36 | 37 | // Retrieve all Properties from the database. 38 | exports.findAll = (req, res) => { 39 | Property.getAll((err, data) => { 40 | if (err) 41 | res.status(500).send({ 42 | message: 43 | err.message || "Some error occurred while retrieving properties." 44 | }); 45 | else res.send(data); 46 | }); 47 | }; 48 | 49 | // Find a single Property with a propertyId 50 | exports.findOne = (req, res) => { 51 | Property.findById(req.params.propertyId, (err, data) => { 52 | if (err) { 53 | if (err.kind === "not_found") { 54 | res.status(404).send({ 55 | message: `Not found Property with id ${req.params.propertyId}.` 56 | }); 57 | } else { 58 | res.status(500).send({ 59 | message: "Error retrieving Property with id " + req.params.propertyId 60 | }); 61 | } 62 | } else res.send(data); 63 | }); 64 | }; 65 | 66 | // Update a Property identified by the propertyId in the request 67 | exports.update = (req, res) => { 68 | // Validate Request 69 | if (!req.body) { 70 | res.status(400).send({ 71 | message: "Content can not be empty!" 72 | }); 73 | } 74 | 75 | console.log(req.body); 76 | 77 | Property.updateById( 78 | req.params.propertyId, 79 | new Property(req.body), 80 | (err, data) => { 81 | if (err) { 82 | if (err.kind === "not_found") { 83 | res.status(404).send({ 84 | message: `Not found Property with id ${req.params.propertyId}.` 85 | }); 86 | } else { 87 | res.status(500).send({ 88 | message: "Error updating Property with id " + req.params.propertyId 89 | }); 90 | } 91 | } else res.send(data); 92 | } 93 | ); 94 | }; 95 | 96 | // Delete a Property with the specified propertyId in the request 97 | exports.delete = (req, res) => { 98 | Property.remove(req.params.propertyId, (err, data) => { 99 | if (err) { 100 | if (err.kind === "not_found") { 101 | res.status(404).send({ 102 | message: `Not found Property with id ${req.params.propertyId}.` 103 | }); 104 | } else { 105 | res.status(500).send({ 106 | message: "Could not delete Property with id " + req.params.propertyId 107 | }); 108 | } 109 | } else res.send({ message: `Property was deleted successfully!` }); 110 | }); 111 | }; 112 | 113 | // Delete all Properties from the database. 114 | exports.deleteAll = (req, res) => { 115 | Property.removeAll((err, data) => { 116 | if (err) 117 | res.status(500).send({ 118 | message: 119 | err.message || "Some error occurred while removing all properties." 120 | }); 121 | else res.send({ message: `All Properties were deleted successfully!` }); 122 | }); 123 | }; 124 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-MYSQL/app/models/db.js: -------------------------------------------------------------------------------- 1 | const mysql = require("mysql"); 2 | const dbConfig = require("../config/db.config.js"); 3 | 4 | var connection = mysql.createPool({ 5 | host: dbConfig.HOST, 6 | user: dbConfig.USER, 7 | password: dbConfig.PASSWORD, 8 | database: dbConfig.DB 9 | }); 10 | 11 | module.exports = connection; 12 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-MYSQL/app/models/property.model.js: -------------------------------------------------------------------------------- 1 | const sql = require("./db.js"); 2 | 3 | // constructor 4 | const Property = function(property) { 5 | this.property_name = property.property_name, 6 | this.address = property.address, 7 | this.city = property.city, 8 | this.country = property.country, 9 | this.type = property.type, 10 | this.minimum_price = property.minimum_price, 11 | this.maximum_price = property.maximum_price, 12 | this.ready_to_sell = property.ready_to_sell 13 | }; 14 | 15 | Property.create = (newProperty, result) => { 16 | sql.query("INSERT INTO properties SET ?", newProperty, (err, res) => { 17 | if (err) { 18 | console.log("error: ", err); 19 | result(err, null); 20 | return; 21 | } 22 | 23 | console.log("created property: ", { id: res.insertId, ...newProperty }); 24 | result(null, { id: res.insertId, ...newProperty }); 25 | }); 26 | }; 27 | 28 | Property.findById = (propertyId, result) => { 29 | sql.query(`SELECT * FROM properties WHERE id = ${propertyId}`, (err, res) => { 30 | if (err) { 31 | console.log("error: ", err); 32 | result(err, null); 33 | return; 34 | } 35 | 36 | if (res.length) { 37 | console.log("found property: ", res[0]); 38 | result(null, res[0]); 39 | return; 40 | } 41 | 42 | // not found Property with the id 43 | result({ kind: "not_found" }, null); 44 | }); 45 | }; 46 | 47 | Property.getAll = result => { 48 | sql.query("SELECT * FROM properties", (err, res) => { 49 | if (err) { 50 | console.log("error: ", err); 51 | result(null, err); 52 | return; 53 | } 54 | 55 | console.log("properties: ", res); 56 | result(null, res); 57 | }); 58 | }; 59 | 60 | Property.updateById = (id, property, result) => { 61 | sql.query( 62 | "UPDATE properties SET property_name = ?, address = ?, city = ?, country = ?, minimum_price = ?, maximum_price = ?, ready_to_sell = ? WHERE id = ?", 63 | [property.property_name, property.address, property.city,property.country, property.minimum_price,property.maximum_price, property.ready_to_sell, id], 64 | (err, res) => { 65 | if (err) { 66 | console.log("error: ", err); 67 | result(null, err); 68 | return; 69 | } 70 | 71 | if (res.affectedRows == 0) { 72 | // not found Property with the id 73 | result({ kind: "not_found" }, null); 74 | return; 75 | } 76 | 77 | console.log("updated property: ", { id: id, ...property }); 78 | result(null, { id: id, ...property }); 79 | } 80 | ); 81 | }; 82 | 83 | Property.remove = (id, result) => { 84 | sql.query("DELETE FROM properties WHERE id = ?", id, (err, res) => { 85 | if (err) { 86 | console.log("error: ", err); 87 | result(null, err); 88 | return; 89 | } 90 | 91 | if (res.affectedRows == 0) { 92 | // not found Property with the id 93 | result({ kind: "not_found" }, null); 94 | return; 95 | } 96 | 97 | console.log("deleted property with id: ", id); 98 | result(null, res); 99 | }); 100 | }; 101 | 102 | Property.removeAll = result => { 103 | sql.query("DELETE FROM properties", (err, res) => { 104 | if (err) { 105 | console.log("error: ", err); 106 | result(null, err); 107 | return; 108 | } 109 | 110 | console.log(`deleted ${res.affectedRows} properties`); 111 | result(null, res); 112 | }); 113 | }; 114 | 115 | module.exports = Property; 116 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-MYSQL/app/routes/property.routes.js: -------------------------------------------------------------------------------- 1 | module.exports = app => { 2 | const properties = require("../controllers/property.controller.js"); 3 | 4 | // Create a new Customer 5 | app.post("/properties", properties.create); 6 | 7 | // Retrieve all Customers 8 | app.get("/properties", properties.findAll); 9 | 10 | // Retrieve a single Customer with propertyId 11 | app.get("/properties/:propertyId", properties.findOne); 12 | 13 | // Update a Customer with propertyId 14 | app.put("/properties/:propertyId", properties.update); 15 | 16 | // Delete a Customer with propertyId 17 | app.delete("/properties/:propertyId", properties.delete); 18 | 19 | // Create a new Customer 20 | app.delete("/properties", properties.deleteAll); 21 | }; 22 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-MYSQL/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-express-mysql", 3 | "version": "1.0.0", 4 | "description": "Node.js Restful CRUD API with Node.js, Express and MySQL", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [ 10 | "nodejs", 11 | "express", 12 | "mysql", 13 | "restapi" 14 | ], 15 | "author": "Sapan Mohanty", 16 | "license": "ISC", 17 | "dependencies": { 18 | "body-parser": "^1.19.0", 19 | "express": "^4.17.1", 20 | "mysql": "^2.18.1" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-MYSQL/server.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const bodyParser = require("body-parser"); 3 | 4 | const app = express(); 5 | 6 | // parse requests of content-type - application/json 7 | app.use(bodyParser.json()); 8 | 9 | // parse requests of content-type - application/x-www-form-urlencoded 10 | app.use(bodyParser.urlencoded({ extended: true })); 11 | 12 | // simple route 13 | app.get("/", (req, res) => { 14 | res.json({ message: "Welcome to Nodejs Simple REST API application." }); 15 | }); 16 | 17 | require("./app/routes/property.routes.js")(app); 18 | 19 | // set port, listen for requests 20 | const PORT = process.env.PORT || 3000; 21 | app.listen(PORT, () => { 22 | console.log(`Server is running on port ${PORT}.`); 23 | }); 24 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/app/config/auth.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | secret: "Sapan-Mohanty-secret-key" 3 | }; 4 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/app/config/db.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | HOST: "localhost", 3 | USER: "root", 4 | PASSWORD: "", 5 | DB: "nodejs", 6 | dialect: "mysql", 7 | pool: { 8 | max: 5, 9 | min: 0, 10 | acquire: 30000, 11 | idle: 10000 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/app/controllers/auth.controller.js: -------------------------------------------------------------------------------- 1 | const db = require("../models"); 2 | const config = require("../config/auth.config"); 3 | const User = db.user; 4 | const Role = db.role; 5 | 6 | const Op = db.Sequelize.Op; 7 | 8 | var jwt = require("jsonwebtoken"); 9 | var bcrypt = require("bcryptjs"); 10 | 11 | exports.signup = (req, res) => { 12 | // Save User to Database 13 | User.create({ 14 | username: req.body.username, 15 | email: req.body.email, 16 | password: bcrypt.hashSync(req.body.password, 8) 17 | }) 18 | .then(user => { 19 | if (req.body.roles) { 20 | Role.findAll({ 21 | where: { 22 | name: { 23 | [Op.or]: req.body.roles 24 | } 25 | } 26 | }).then(roles => { 27 | user.setRoles(roles).then(() => { 28 | res.send({ message: "User registered successfully!" }); 29 | }); 30 | }); 31 | } else { 32 | // user role = 1 33 | user.setRoles([1]).then(() => { 34 | res.send({ message: "User registered successfully!" }); 35 | }); 36 | } 37 | }) 38 | .catch(err => { 39 | res.status(500).send({ message: err.message }); 40 | }); 41 | }; 42 | 43 | exports.signin = (req, res) => { 44 | User.findOne({ 45 | where: { 46 | username: req.body.username 47 | } 48 | }) 49 | .then(user => { 50 | if (!user) { 51 | return res.status(404).send({ message: "User Not found." }); 52 | } 53 | 54 | var passwordIsValid = bcrypt.compareSync( 55 | req.body.password, 56 | user.password 57 | ); 58 | 59 | if (!passwordIsValid) { 60 | return res.status(401).send({ 61 | accessToken: null, 62 | message: "Invalid Password!" 63 | }); 64 | } 65 | 66 | var token = jwt.sign({ id: user.id }, config.secret, { 67 | expiresIn: 86400 // 24 hours 68 | }); 69 | 70 | var authorities = []; 71 | user.getRoles().then(roles => { 72 | for (let i = 0; i < roles.length; i++) { 73 | authorities.push("ROLE_" + roles[i].name.toUpperCase()); 74 | } 75 | res.status(200).send({ 76 | id: user.id, 77 | username: user.username, 78 | email: user.email, 79 | roles: authorities, 80 | accessToken: token 81 | }); 82 | }); 83 | }) 84 | .catch(err => { 85 | res.status(500).send({ message: err.message }); 86 | }); 87 | }; 88 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/app/controllers/user.controller.js: -------------------------------------------------------------------------------- 1 | exports.allAccess = (req, res) => { 2 | res.status(200).send("Public Content."); 3 | }; 4 | 5 | exports.userBoard = (req, res) => { 6 | res.status(200).send("User Content."); 7 | }; 8 | 9 | exports.adminBoard = (req, res) => { 10 | res.status(200).send("Admin Content."); 11 | }; -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/app/middleware/authJwt.js: -------------------------------------------------------------------------------- 1 | const jwt = require("jsonwebtoken"); 2 | const config = require("../config/auth.config.js"); 3 | const db = require("../models"); 4 | const User = db.user; 5 | 6 | verifyToken = (req, res, next) => { 7 | let token = req.headers["x-access-token"]; 8 | 9 | if (!token) { 10 | return res.status(403).send({ 11 | message: "No token provided!" 12 | }); 13 | } 14 | 15 | jwt.verify(token, config.secret, (err, decoded) => { 16 | if (err) { 17 | return res.status(401).send({ 18 | message: "Unauthorized!" 19 | }); 20 | } 21 | req.userId = decoded.id; 22 | next(); 23 | }); 24 | }; 25 | 26 | isAdmin = (req, res, next) => { 27 | User.findByPk(req.userId).then(user => { 28 | user.getRoles().then(roles => { 29 | for (let i = 0; i < roles.length; i++) { 30 | if (roles[i].name === "admin") { 31 | next(); 32 | return; 33 | } 34 | } 35 | res.status(403).send({ 36 | message: "Require Admin Role!" 37 | }); 38 | return; 39 | }); 40 | }); 41 | }; 42 | const authJwt = { 43 | verifyToken: verifyToken, 44 | isAdmin: isAdmin 45 | }; 46 | module.exports = authJwt; 47 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/app/middleware/index.js: -------------------------------------------------------------------------------- 1 | const authJwt = require("./authJwt"); 2 | const verifySignUp = require("./verifySignUp"); 3 | 4 | module.exports = { 5 | authJwt, 6 | verifySignUp 7 | }; 8 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/app/middleware/verifySignUp.js: -------------------------------------------------------------------------------- 1 | const db = require("../models"); 2 | const ROLES = db.ROLES; 3 | const User = db.user; 4 | 5 | checkDuplicateUsernameOrEmail = (req, res, next) => { 6 | // Username 7 | User.findOne({ 8 | where: { 9 | username: req.body.username 10 | } 11 | }).then(user => { 12 | if (user) { 13 | res.status(400).send({ 14 | message: "Failed! Username is already in use!" 15 | }); 16 | return; 17 | } 18 | 19 | // Email 20 | User.findOne({ 21 | where: { 22 | email: req.body.email 23 | } 24 | }).then(user => { 25 | if (user) { 26 | res.status(400).send({ 27 | message: "Failed! Email is already in use!" 28 | }); 29 | return; 30 | } 31 | 32 | next(); 33 | }); 34 | }); 35 | }; 36 | 37 | checkRolesExisted = (req, res, next) => { 38 | if (req.body.roles) { 39 | for (let i = 0; i < req.body.roles.length; i++) { 40 | if (!ROLES.includes(req.body.roles[i])) { 41 | res.status(400).send({ 42 | message: "Failed! Role does not exist = " + req.body.roles[i] 43 | }); 44 | return; 45 | } 46 | } 47 | } 48 | 49 | next(); 50 | }; 51 | 52 | const verifySignUp = { 53 | checkDuplicateUsernameOrEmail: checkDuplicateUsernameOrEmail, 54 | checkRolesExisted: checkRolesExisted 55 | }; 56 | 57 | module.exports = verifySignUp; 58 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/app/models/index.js: -------------------------------------------------------------------------------- 1 | const config = require("../config/db.config.js"); 2 | 3 | const Sequelize = require("sequelize"); 4 | const sequelize = new Sequelize( 5 | config.DB, 6 | config.USER, 7 | config.PASSWORD, 8 | { 9 | host: config.HOST, 10 | dialect: config.dialect, 11 | operatorsAliases: false, 12 | 13 | pool: { 14 | max: config.pool.max, 15 | min: config.pool.min, 16 | acquire: config.pool.acquire, 17 | idle: config.pool.idle 18 | } 19 | } 20 | ); 21 | 22 | const db = {}; 23 | 24 | db.Sequelize = Sequelize; 25 | db.sequelize = sequelize; 26 | db.sequelize = sequelize; 27 | 28 | 29 | db.user = require("../models/user.model.js")(sequelize, Sequelize); 30 | db.role = require("../models/role.model.js")(sequelize, Sequelize); 31 | db.property = require("../models/property.model.js")(sequelize, Sequelize); 32 | 33 | 34 | db.role.belongsToMany(db.user, { 35 | through: "user_roles", 36 | foreignKey: "roleId", 37 | otherKey: "userId" 38 | }); 39 | db.user.belongsToMany(db.role, { 40 | through: "user_roles", 41 | foreignKey: "userId", 42 | otherKey: "roleId" 43 | }); 44 | 45 | db.ROLES = ["user", "admin"]; 46 | 47 | module.exports = db; 48 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/app/models/property.model.js: -------------------------------------------------------------------------------- 1 | module.exports = (sequelize, Sequelize) => { 2 | const Property = sequelize.define("properties", { 3 | property_name: { 4 | type: Sequelize.STRING 5 | }, 6 | address: { 7 | type: Sequelize.STRING 8 | }, 9 | city: { 10 | type: Sequelize.STRING 11 | }, 12 | country: { 13 | type: Sequelize.STRING 14 | }, 15 | minimum_price: { 16 | type: Sequelize.DECIMAL 17 | }, 18 | maximum_price: { 19 | type: Sequelize.DECIMAL 20 | }, 21 | ready_to_sell: { 22 | type: Sequelize.INTEGER 23 | } 24 | }, { 25 | timestamps: false 26 | }); 27 | 28 | return Property; 29 | }; -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/app/models/role.model.js: -------------------------------------------------------------------------------- 1 | module.exports = (sequelize, Sequelize) => { 2 | const Role = sequelize.define("roles", { 3 | id: { 4 | type: Sequelize.INTEGER, 5 | primaryKey: true 6 | }, 7 | name: { 8 | type: Sequelize.STRING 9 | } 10 | }); 11 | 12 | return Role; 13 | }; 14 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/app/models/user.model.js: -------------------------------------------------------------------------------- 1 | module.exports = (sequelize, Sequelize) => { 2 | const User = sequelize.define("users", { 3 | username: { 4 | type: Sequelize.STRING 5 | }, 6 | email: { 7 | type: Sequelize.STRING 8 | }, 9 | password: { 10 | type: Sequelize.STRING 11 | } 12 | }); 13 | 14 | return User; 15 | }; 16 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/app/routes/auth.routes.js: -------------------------------------------------------------------------------- 1 | const { verifySignUp } = require("../middleware"); 2 | const controller = require("../controllers/auth.controller"); 3 | 4 | module.exports = function(app) { 5 | app.use(function(req, res, next) { 6 | res.header( 7 | "Access-Control-Allow-Headers", 8 | "x-access-token, Origin, Content-Type, Accept" 9 | ); 10 | next(); 11 | }); 12 | 13 | app.post( 14 | "/api/auth/signup", 15 | [ 16 | verifySignUp.checkDuplicateUsernameOrEmail, 17 | verifySignUp.checkRolesExisted 18 | ], 19 | controller.signup 20 | ); 21 | 22 | app.post("/api/auth/signin", controller.signin); 23 | }; 24 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/app/routes/property.routes.js: -------------------------------------------------------------------------------- 1 | const { authJwt } = require("../middleware"); 2 | const properties = require("../controllers/property.controller"); 3 | 4 | module.exports = function(app) { 5 | app.use(function(req, res, next) { 6 | res.header( 7 | "Access-Control-Allow-Headers", 8 | "x-access-token, Origin, Content-Type, Accept" 9 | ); 10 | next(); 11 | }); 12 | 13 | app.get("/properties/", [authJwt.verifyToken], properties.findAll); 14 | 15 | app.post("/properties/", [authJwt.verifyToken], properties.create); 16 | 17 | // Retrieve all Properties 18 | app.get("/properties/", [authJwt.verifyToken, authJwt.isAdmin], properties.findAll); 19 | 20 | // Retrieve a single Property with id 21 | app.get("/properties/:id", [authJwt.verifyToken, authJwt.isAdmin], properties.findOne); 22 | 23 | // Update a Property with id 24 | app.put("/properties/:id", [authJwt.verifyToken, authJwt.isAdmin], properties.update); 25 | 26 | // Delete a Property with id 27 | app.delete("/properties/:id", [authJwt.verifyToken, authJwt.isAdmin], properties.delete); 28 | 29 | // Delete all Properties 30 | app.delete("/properties/", [authJwt.verifyToken, authJwt.isAdmin], properties.deleteAll); 31 | 32 | 33 | }; 34 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/app/routes/user.routes.js: -------------------------------------------------------------------------------- 1 | const { authJwt } = require("../middleware"); 2 | const controller = require("../controllers/user.controller"); 3 | 4 | module.exports = function(app) { 5 | app.use(function(req, res, next) { 6 | res.header( 7 | "Access-Control-Allow-Headers", 8 | "x-access-token, Origin, Content-Type, Accept" 9 | ); 10 | next(); 11 | }); 12 | 13 | app.get("/api/test/all", controller.allAccess); 14 | 15 | app.get( 16 | "/api/test/user", 17 | [authJwt.verifyToken], 18 | controller.userBoard 19 | ); 20 | 21 | app.get( 22 | "/api/test/admin", 23 | [authJwt.verifyToken, authJwt.isAdmin], 24 | controller.adminBoard 25 | ); 26 | }; 27 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "NODEJS-JWT", 3 | "version": "1.0.0", 4 | "description": "Node.js and Express REST API with JWT Authentication", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [ 10 | "node.js", 11 | "jwt", 12 | "authentication", 13 | "express", 14 | "mysql" 15 | ], 16 | "author": "Sapan Mohanty", 17 | "license": "ISC", 18 | "dependencies": { 19 | "bcryptjs": "^2.4.3", 20 | "body-parser": "^1.19.0", 21 | "cors": "^2.8.5", 22 | "express": "^4.17.1", 23 | "jsonwebtoken": "^8.5.1", 24 | "mysql2": "^2.2.5", 25 | "sequelize": "^5.22.3" 26 | }, 27 | "devDependencies": { 28 | "nodemon": "^2.0.6" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /NODEJS-EXPRESS-SEQUELlZE-JWT-AUTH/server.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const bodyParser = require("body-parser"); 3 | const cors = require("cors"); 4 | 5 | const app = express(); 6 | 7 | var corsOptions = { 8 | origin: "http://localhost:8081" 9 | }; 10 | 11 | app.use(cors(corsOptions)); 12 | 13 | // parse requests of content-type - application/json 14 | app.use(bodyParser.json()); 15 | 16 | // parse requests of content-type - application/x-www-form-urlencoded 17 | app.use(bodyParser.urlencoded({ extended: true })); 18 | 19 | // database 20 | const db = require("./app/models"); 21 | const Role = db.role; 22 | 23 | db.sequelize.sync(); 24 | // force: true will drop the table if it already exists 25 | // db.sequelize.sync({force: true}).then(() => { 26 | // console.log('Drop and Resync Database with { force: true }'); 27 | // initial(); 28 | // }); 29 | 30 | // simple route 31 | app.get("/", (req, res) => { 32 | res.json({ message: "Express API is Ready" }); 33 | }); 34 | 35 | // routes 36 | require('./app/routes/auth.routes')(app); 37 | require('./app/routes/user.routes')(app); 38 | require('./app/routes/property.routes')(app); 39 | 40 | // set port, listen for requests 41 | const PORT = process.env.PORT || 8080; 42 | app.listen(PORT, () => { 43 | console.log(`Server is running on port ${PORT}.`); 44 | }); 45 | 46 | function initial() { 47 | Role.create({ 48 | id: 1, 49 | name: "user" 50 | }); 51 | 52 | Role.create({ 53 | id: 2, 54 | name: "admin" 55 | }); 56 | } -------------------------------------------------------------------------------- /PHP-OOPS/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "firebase/php-jwt": "^5.2" 4 | 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /PHP-OOPS/config/DatabasImport.sql: -------------------------------------------------------------------------------- 1 | /* Import These Data into your Database*/ 2 | 3 | /*Table structure for table `books` */ 4 | 5 | DROP TABLE IF EXISTS `books`; 6 | 7 | CREATE TABLE `books` ( 8 | `book_id` int(11) NOT NULL AUTO_INCREMENT, 9 | `title` varchar(255) DEFAULT NULL, 10 | `author_name` varchar(55) DEFAULT NULL, 11 | `isbn` int(15) DEFAULT NULL, 12 | `release_date` date DEFAULT NULL, 13 | `last_update` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(), 14 | `user_id` int(11) DEFAULT NULL, 15 | PRIMARY KEY (`book_id`), 16 | UNIQUE KEY `UNIQUE_ISBN` (`isbn`) 17 | ) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8mb4; 18 | 19 | /*Data for the table `books` */ 20 | 21 | insert into `books`(`book_id`,`title`,`author_name`,`isbn`,`release_date`,`last_update`,`user_id`) values 22 | 23 | (16,'Indian Politics 2021','test 1',1360918141,NULL,'2020-06-25 15:46:21',1), 24 | 25 | (22,'Indian Politics','test',78888888,NULL,'2020-06-25 15:32:15',1), 26 | 27 | (25,'Indian Politics','test',788888891,NULL,'2020-06-25 15:33:45',1), 28 | 29 | (29,'Indian Politics','test',1861972717,NULL,'2020-06-26 08:03:43',1); 30 | 31 | /*Table structure for table `users` */ 32 | 33 | DROP TABLE IF EXISTS `users`; 34 | 35 | CREATE TABLE `users` ( 36 | `user_id` int(11) NOT NULL AUTO_INCREMENT, 37 | `user_name` varchar(50) DEFAULT NULL, 38 | `email` varchar(50) DEFAULT NULL, 39 | `password` varchar(50) DEFAULT NULL, 40 | PRIMARY KEY (`user_id`) 41 | ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4; 42 | 43 | /*Data for the table `users` */ 44 | 45 | insert into `users`(`user_id`,`user_name`,`email`,`password`) values 46 | 47 | (1,'sapan','ctoattraveltech@gmail.com','c1bdcee164660e8bcf4eabbc2ad9d470'), 48 | 49 | (2,'akram','akram@shoppinpal.com','c1bdcee164660e8bcf4eabbc2ad9d470'); 50 | 51 | 52 | -------------------------------------------------------------------------------- /PHP-OOPS/config/Database.php: -------------------------------------------------------------------------------- 1 | conn = null; 15 | try { 16 | $this->conn = new PDO('mysql:host=' . $this->host . ';dbname=' . $this->dbName, $this->userName, $this->password); 17 | $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 18 | } catch (PDOException $e) { 19 | echo 'Connection Error: '. $e->getMessage(); 20 | } 21 | return $this->conn; 22 | } 23 | } -------------------------------------------------------------------------------- /PHP-OOPS/index.php: -------------------------------------------------------------------------------- 1 | storeApi($postData); 13 | ?> 14 | -------------------------------------------------------------------------------- /PHP-OOPS/readme.txt: -------------------------------------------------------------------------------- 1 | /** 2 | * @Date 25-06-2020 3 | * @Author Sapan Mohanty 4 | * @Skype sapan.mohannty 5 | * @github https://github.com/travelxml 6 | */ 7 | 8 | Basic testing done for all functions like create, update, read & delete book 9 | This can be extend with more functionalities like input and output validation & parameters matching 10 | 11 | 12 | All this test conducted using HTTP_Request2 PEAR library 13 | 14 | For more details you visit: https://pear.php.net/manual/en/package.http.http-request2.config.php 15 | 16 | After Download the script, got to project directory and RUN 'composer update' -------------------------------------------------------------------------------- /PHP-OOPS/test/CreateBook.php: -------------------------------------------------------------------------------- 1 | setUrl('http://localhost/bookstore/'); 5 | $request->setMethod(HTTP_Request2::METHOD_POST); 6 | $request->setConfig(array( 7 | 'follow_redirects' => TRUE 8 | )); 9 | $request->setHeader(array( 10 | 'Auth' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwidXNlcl9uYW1lIjoic2FwYW4iLCJlbWFpbCI6ImN0b2F0dHJhdmVsdGVjaEBnbWFpbC5jb20ifQ.YuuHvX8IdNFugj0_1xiEbZ9f54PAnaExO9Xv_rjB4Rg' 11 | )); 12 | $request->setBody('{ 13 | "author_name":"test", 14 | "title":"Indian Politics", 15 | "isbn":"1861972717", 16 | "release_date":"", 17 | "action":"create_book"}'); 18 | try { 19 | $response = $request->send(); 20 | echo '
INPUT :'. $request->getBody(); 21 | 22 | echo'

OUTPUT Header :'.implode(" | ",$response->getHeader()); 23 | 24 | 25 | if ($response->getStatus() == 200) { 26 | echo '
HTTP status: ' . $response->getStatus(); 27 | 28 | echo '

OUTPUT :'.$output = $response->getBody(); 29 | } 30 | else { 31 | echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' . 32 | $response->getReasonPhrase(); 33 | } 34 | } 35 | catch(HTTP_Request2_Exception $e) { 36 | echo 'Error: ' . $e->getMessage(); 37 | }?> -------------------------------------------------------------------------------- /PHP-OOPS/test/DeleteBook.php: -------------------------------------------------------------------------------- 1 | setUrl('http://localhost/bookstore/'); 5 | $request->setMethod(HTTP_Request2::METHOD_POST); 6 | $request->setConfig(array( 7 | 'follow_redirects' => TRUE 8 | )); 9 | $request->setHeader(array( 10 | 'Auth' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwidXNlcl9uYW1lIjoic2FwYW4iLCJlbWFpbCI6ImN0b2F0dHJhdmVsdGVjaEBnbWFpbC5jb20ifQ.YuuHvX8IdNFugj0_1xiEbZ9f54PAnaExO9Xv_rjB4Rg' 11 | )); 12 | $input = '{"id":"29", "action":"delete_book"}'; 13 | $request->setBody($input); 14 | try { 15 | $response = $request->send(); 16 | echo '
INPUT :'. $request->getBody(); 17 | 18 | echo'

OUTPUT Header :'.implode(" | ",$response->getHeader()); 19 | 20 | 21 | if ($response->getStatus() == 200) { 22 | echo '
HTTP status: ' . $response->getStatus(); 23 | 24 | echo '

OUTPUT :'.$output = $response->getBody(); 25 | } 26 | else { 27 | echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' . 28 | $response->getReasonPhrase(); 29 | } 30 | } 31 | catch(HTTP_Request2_Exception $e) { 32 | echo 'Error: ' . $e->getMessage(); 33 | }?> -------------------------------------------------------------------------------- /PHP-OOPS/test/ReadBook.php: -------------------------------------------------------------------------------- 1 | setUrl('http://localhost/bookstore/'); 5 | $request->setMethod(HTTP_Request2::METHOD_POST); 6 | $request->setConfig(array( 7 | 'follow_redirects' => TRUE 8 | )); 9 | $request->setHeader(array( 10 | 'Auth' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwidXNlcl9uYW1lIjoic2FwYW4iLCJlbWFpbCI6ImN0b2F0dHJhdmVsdGVjaEBnbWFpbC5jb20ifQ.YuuHvX8IdNFugj0_1xiEbZ9f54PAnaExO9Xv_rjB4Rg' 11 | )); 12 | $request->setBody('{"action":"read_book"}'); 13 | try { 14 | $response = $request->send(); 15 | echo '
INPUT :'. $request->getBody(); 16 | 17 | echo'

OUTPUT Header :'.implode(" | ",$response->getHeader()); 18 | 19 | 20 | if ($response->getStatus() == 200) { 21 | echo '
HTTP status: ' . $response->getStatus(); 22 | 23 | echo '

OUTPUT :'.$output = $response->getBody(); 24 | } 25 | else { 26 | echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' . 27 | $response->getReasonPhrase(); 28 | } 29 | } 30 | catch(HTTP_Request2_Exception $e) { 31 | echo 'Error: ' . $e->getMessage(); 32 | } -------------------------------------------------------------------------------- /PHP-OOPS/test/ReadBookSingle.php: -------------------------------------------------------------------------------- 1 | setUrl('http://localhost/bookstore/'); 5 | $request->setMethod(HTTP_Request2::METHOD_POST); 6 | $request->setConfig(array( 7 | 'follow_redirects' => TRUE 8 | )); 9 | $request->setHeader(array( 10 | 'Auth' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwidXNlcl9uYW1lIjoic2FwYW4iLCJlbWFpbCI6ImN0b2F0dHJhdmVsdGVjaEBnbWFpbC5jb20ifQ.YuuHvX8IdNFugj0_1xiEbZ9f54PAnaExO9Xv_rjB4Rg' 11 | )); 12 | $request->setBody('{ "id":"16", "action":"read_book"}'); 13 | try { 14 | $response = $request->send(); 15 | echo '
INPUT :'. $request->getBody(); 16 | 17 | echo'

OUTPUT Header :'.implode(" | ",$response->getHeader()); 18 | 19 | 20 | if ($response->getStatus() == 200) { 21 | echo '
HTTP status: ' . $response->getStatus(); 22 | 23 | echo '

OUTPUT :'.$output = $response->getBody(); 24 | } 25 | else { 26 | echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' . 27 | $response->getReasonPhrase(); 28 | } 29 | } 30 | catch(HTTP_Request2_Exception $e) { 31 | echo 'Error: ' . $e->getMessage(); 32 | } -------------------------------------------------------------------------------- /PHP-OOPS/test/UpdateBook.php: -------------------------------------------------------------------------------- 1 | setUrl('http://localhost/bookstore/'); 5 | $request->setMethod(HTTP_Request2::METHOD_POST); 6 | $request->setConfig(array( 7 | 'follow_redirects' => TRUE 8 | )); 9 | $request->setHeader(array( 10 | 'Auth' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwidXNlcl9uYW1lIjoic2FwYW4iLCJlbWFpbCI6ImN0b2F0dHJhdmVsdGVjaEBnbWFpbC5jb20ifQ.YuuHvX8IdNFugj0_1xiEbZ9f54PAnaExO9Xv_rjB4Rg' 11 | )); 12 | $request->setBody('{ "id":12, 13 | "author_name":"test", 14 | "title":"Indian Politics 2020", 15 | "isbn":"01360918141", 16 | "release_date":"", 17 | "action":"update_book" 18 | }'); 19 | try { 20 | $response = $request->send(); 21 | echo '
INPUT :'. $request->getBody(); 22 | 23 | echo'

OUTPUT Header :'.implode(" | ",$response->getHeader()); 24 | 25 | 26 | if ($response->getStatus() == 200) { 27 | echo '
HTTP status: ' . $response->getStatus(); 28 | 29 | echo '

OUTPUT :'.$output = $response->getBody(); 30 | } 31 | else { 32 | echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' . 33 | $response->getReasonPhrase(); 34 | } 35 | } 36 | catch(HTTP_Request2_Exception $e) { 37 | echo 'Error: ' . $e->getMessage(); 38 | } -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/db.sqlite3 -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'msite.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/msite/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/msite/__init__.py -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/msite/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/msite/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/msite/__pycache__/settings.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/msite/__pycache__/settings.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/msite/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/msite/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/msite/__pycache__/wsgi.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/msite/__pycache__/wsgi.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/msite/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for msite project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'msite.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/msite/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for msite project. 3 | 4 | Generated by 'django-admin startproject' using Django 3.1.4. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.1/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/3.1/ref/settings/ 11 | """ 12 | 13 | from pathlib import Path 14 | 15 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 16 | BASE_DIR = Path(__file__).resolve().parent.parent 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '3a@1@lhexwz+%^e9t6r9wtjruw*o+l_oc&p6kb=ii%$5xsd9$s' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'rest.apps.RestConfig', 41 | 'rest_framework', 42 | ] 43 | 44 | MIDDLEWARE = [ 45 | 'django.middleware.security.SecurityMiddleware', 46 | 'django.contrib.sessions.middleware.SessionMiddleware', 47 | 'django.middleware.common.CommonMiddleware', 48 | 'django.middleware.csrf.CsrfViewMiddleware', 49 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 50 | 'django.contrib.messages.middleware.MessageMiddleware', 51 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 52 | ] 53 | 54 | ROOT_URLCONF = 'msite.urls' 55 | 56 | TEMPLATES = [ 57 | { 58 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 59 | 'DIRS': [], 60 | 'APP_DIRS': True, 61 | 'OPTIONS': { 62 | 'context_processors': [ 63 | 'django.template.context_processors.debug', 64 | 'django.template.context_processors.request', 65 | 'django.contrib.auth.context_processors.auth', 66 | 'django.contrib.messages.context_processors.messages', 67 | ], 68 | }, 69 | }, 70 | ] 71 | 72 | WSGI_APPLICATION = 'msite.wsgi.application' 73 | 74 | 75 | # Database 76 | # https://docs.djangoproject.com/en/3.1/ref/settings/#databases 77 | 78 | DATABASES = { 79 | 'default': { 80 | 'ENGINE': 'django.db.backends.sqlite3', 81 | 'NAME': BASE_DIR / 'db.sqlite3', 82 | } 83 | } 84 | 85 | 86 | # Password validation 87 | # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators 88 | 89 | AUTH_PASSWORD_VALIDATORS = [ 90 | { 91 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 92 | }, 93 | { 94 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 95 | }, 96 | { 97 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 98 | }, 99 | { 100 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 101 | }, 102 | ] 103 | 104 | 105 | # Internationalization 106 | # https://docs.djangoproject.com/en/3.1/topics/i18n/ 107 | 108 | LANGUAGE_CODE = 'en-us' 109 | 110 | TIME_ZONE = 'UTC' 111 | 112 | USE_I18N = True 113 | 114 | USE_L10N = True 115 | 116 | USE_TZ = True 117 | 118 | 119 | # Static files (CSS, JavaScript, Images) 120 | # https://docs.djangoproject.com/en/3.1/howto/static-files/ 121 | 122 | STATIC_URL = '/static/' 123 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/msite/urls.py: -------------------------------------------------------------------------------- 1 | """msite URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/3.1/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path, include 18 | 19 | urlpatterns = [ 20 | path('admin/', admin.site.urls), 21 | path('', include('rest.urls')), 22 | ] 23 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/msite/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for msite project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'msite.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/readme.md: -------------------------------------------------------------------------------- 1 | ## DJANGO REST API Tutorial - CURD with DJANGO, REST Framework[2021] 2 | 3 | ![DJANGO REST API Tutorial - CURD with DJANGO, REST Framework[2021]](https://github.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/blob/main/images/Django-REST-API.png) 4 | 5 | 6 | Create a RESTful web service for a Library. The service must have the following API endpoints: 7 | 8 | (C)reate a new Book 9 | (R)ead existing Books 10 | (U)pdate an existing Book 11 | (D)elete an existing Book 12 | 13 | A Book entity has the following properties: 14 | 15 | Author (mandatory) 16 | Title (mandatory) 17 | ISBN (mandatory) 18 | Release Date 19 | 20 | # Implementation(s) 21 | 22 | #### Create a project folder as 'rest-api' 23 | 24 | Go to project folder >> 'rest-api' 25 | 26 | #### Setup virtualenv in this project folder: 27 | 28 | $ pip3.8 install virtualenv 29 | $ virtualenv venv --python=python3.8 30 | 31 | #### Activate Virtual Environment 32 | 33 | $ source venv/bin/activate - Mac / Linux 34 | venv\Scripts\activate.bat - Windows 35 | 36 | #### Now, we can install Django: 37 | 38 | $ pip3 install django 39 | 40 | #### Next, let’s start a new Django project: 41 | 42 | $ django-admin startproject msite 43 | 44 | #### If we look at the directory now, we’ll see that Django created a new folder for us: 45 | 46 | $ ls 47 | msite/ 48 | 49 | #### And if we look inside that folder, there’s everything we need to run a Django site: 50 | $ cd msite/ 51 | $ ls 52 | manage.py* msite/ 53 | 54 | #### Let’s make sure it works. Test run the Django server: 55 | 56 | $ python3 manage.py runserver 57 | 58 | Watching for file changes with StatReloader 59 | Performing system checks...System check identified no issues (0 silenced).You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. 60 | Run 'python manage.py migrate' to apply them.May 17, 2019 - 16:09:28 61 | Django version 2.2.1, using settings 'msite.settings' 62 | Starting development server at http://127.0.0.1:8000/ 63 | Quit the server with CONTROL-C. 64 | 65 | #### Go to localhost:8000 and you should see the Django welcome screen! 66 | 67 | ![Django Server Look Like](https://github.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/blob/main/images/django-local-server-up.png) 68 | 69 | #### [Download](https://github.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/tree/main/DJANGO-REST-FRAMEWORK) the code and drop and replace with msite of project folder 'rest-api' with download msite 70 | 71 | #### API is ready to RUN 72 | 73 | $ cd msite 74 | 75 | #### Ready to up server 76 | 77 | $ python3 manage.py runserver 78 | 79 | #### End Points 80 | 81 | 1- Stores 82 | ![Stores](https://github.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/blob/main/images/django-restframework-stores.png) 83 | 84 | 2- Books 85 | ![Books](https://github.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/blob/main/images/django-restframework-books.png) 86 | 87 | 88 | 89 | 90 | **Python Version: 3.8**
91 | 92 | 93 | **Request :** All request should be JSON data
94 | 95 | **Response :** JSON data
96 | 97 | I hope instructions are good to set up this project in your local, Enjoy Coding :+1: 98 | 99 | ![Back to HOME](https://github.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples) 100 | 101 | #### For Help, you can reach 102 | ------------------------------- 103 | Skype: sapan.mohannty 104 | 105 | Twitter: https://twitter.com/htngapi 106 | 107 | Linkedin: https://www.linkedin.com/in/travel-technology-cto/ 108 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/readme.md.bak: -------------------------------------------------------------------------------- 1 | ## REST API - CURD with PYTHON, DJANGO, REST Framework 2 | 3 | ![REST API DJANGO REST FRAMEWORK](https://github.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/blob/main/images/Django-REST-API.png) 4 | 5 | 6 | Create a RESTful web service for a Library. The service must have the following API endpoints: 7 | 8 | (C)reate a new Book 9 | (R)ead existing Books 10 | (U)pdate an existing Book 11 | (D)elete an existing Book 12 | 13 | A Book entity has the following properties: 14 | 15 | Author (mandatory) 16 | Title (mandatory) 17 | ISBN (mandatory) 18 | Release Date 19 | 20 | # Implementation(s) 21 | 22 | #### Create a project folder as 'rest-api' 23 | 24 | Go to project folder >> 'rest-api' 25 | 26 | #### Setup virtualenv in this project folder: 27 | 28 | $ pip3.8 install virtualenv 29 | $ virtualenv venv --python=python3.8 30 | 31 | #### Activate Virtual Environment 32 | 33 | $ source venv/bin/activate - Mac / Linux 34 | venv\Scripts\activate.bat - Windows 35 | 36 | #### Now, we can install Django: 37 | 38 | $ pip3 install django 39 | 40 | #### Next, let’s start a new Django project: 41 | 42 | $ django-admin startproject msite 43 | 44 | #### If we look at the directory now, we’ll see that Django created a new folder for us: 45 | 46 | $ ls 47 | msite/ 48 | 49 | #### And if we look inside that folder, there’s everything we need to run a Django site: 50 | $ cd msite/ 51 | $ ls 52 | manage.py* msite/ 53 | 54 | #### Let’s make sure it works. Test run the Django server: 55 | 56 | $ python3 manage.py runserver 57 | 58 | Watching for file changes with StatReloader 59 | Performing system checks...System check identified no issues (0 silenced).You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. 60 | Run 'python manage.py migrate' to apply them.May 17, 2019 - 16:09:28 61 | Django version 2.2.1, using settings 'msite.settings' 62 | Starting development server at http://127.0.0.1:8000/ 63 | Quit the server with CONTROL-C. 64 | 65 | #### Go to localhost:8000 and you should see the Django welcome screen! 66 | 67 | ![Django Server Look Like](https://github.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/blob/main/images/django-local-server-up.png) 68 | 69 | #### [Download](https://github.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/tree/main/DJANGO-REST-FRAMEWORK) the code and drop and replace with msite of project folder 'rest-api' with download msite 70 | 71 | #### API is ready to RUN 72 | 73 | $ cd msite 74 | 75 | #### Ready to up server 76 | 77 | $ python3 manage.py runserver 78 | 79 | #### End Points 80 | 81 | 1- Stores 82 | ![Stores](https://github.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/blob/main/images/django-restframework-stores.png) 83 | 84 | 2- Books 85 | ![Books](https://github.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/blob/main/images/django-restframework-books.png) 86 | 87 | 88 | 89 | 90 | **Python Version: 3.8**
91 | 92 | 93 | **Request :** All request should be JSON data
94 | 95 | **Response :** JSON data
96 | 97 | Enjoy coding! :)
98 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/rest/__init__.py -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/rest/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/__pycache__/admin.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/rest/__pycache__/admin.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/__pycache__/apps.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/rest/__pycache__/apps.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/__pycache__/models.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/rest/__pycache__/models.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/__pycache__/serializers.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/rest/__pycache__/serializers.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/rest/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/__pycache__/views.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/rest/__pycache__/views.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | #from .models import Hero 5 | #admin.site.register(Hero) 6 | 7 | #from .models import Book 8 | #admin.site.register(Book) 9 | #from .models import Tutorial, TutorialSeries, TutorialCategory 10 | #class TutorialAdmin(admin.ModelAdmin): 11 | 12 | # fieldsets = [ 13 | # ("Title/date", {'fields': ["tutorial_title", "tutorial_published"]}), 14 | # ("URL", {'fields': ["tutorial_slug"]}), 15 | # ("Series", {'fields': ["tutorial_series"]}), 16 | # ("Content", {"fields": ["tutorial_content"]}) 17 | # ] 18 | # 19 | # formfield_overrides = { 20 | # models.TextField: {'widget': TinyMCE(attrs={'cols': 80, 'rows': 30})}, 21 | # } 22 | 23 | 24 | #admin.site.register(TutorialSeries) 25 | #admin.site.register(TutorialCategory) 26 | #admin.site.register(Tutorial) 27 | from .models import Register, Store, Book 28 | 29 | class BookAdmin(admin.ModelAdmin): 30 | list_display = ("store_id", "title", "author", "isbn", "release_date") 31 | 32 | class StoreAdmin(admin.ModelAdmin): 33 | list_display = ("store_id", "store_name") 34 | 35 | class userAdmin(admin.ModelAdmin): 36 | list_display = ("user_id", "user_name", "user_password") 37 | 38 | 39 | admin.site.register(Register, userAdmin) 40 | admin.site.register(Store, StoreAdmin) 41 | admin.site.register(Book, BookAdmin) 42 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class RestConfig(AppConfig): 5 | name = 'rest' 6 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.1.4 on 2020-12-07 01:56 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Hero', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('name', models.CharField(max_length=60)), 19 | ('alias', models.CharField(max_length=60)), 20 | ], 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/0002_book.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.1.4 on 2020-12-07 01:59 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('rest', '0001_initial'), 10 | ] 11 | 12 | operations = [ 13 | migrations.CreateModel( 14 | name='Book', 15 | fields=[ 16 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 17 | ('author', models.CharField(max_length=60)), 18 | ('title', models.CharField(max_length=60)), 19 | ('isbn', models.CharField(max_length=30)), 20 | ('release_date', models.DateField(null=True)), 21 | ], 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/0003_auto_20201207_0231.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.1.4 on 2020-12-07 02:31 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('rest', '0002_book'), 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Tutorial', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('tutorial_title', models.CharField(max_length=200)), 19 | ('tutorial_content', models.TextField()), 20 | ('tutorial_published', models.DateTimeField(verbose_name='date published')), 21 | ('tutorial_slug', models.CharField(default=1, max_length=200)), 22 | ], 23 | ), 24 | migrations.CreateModel( 25 | name='TutorialCategory', 26 | fields=[ 27 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 28 | ('tutorial_category', models.CharField(max_length=200)), 29 | ('category_summary', models.CharField(max_length=200)), 30 | ('category_slug', models.CharField(default=1, max_length=200)), 31 | ], 32 | options={ 33 | 'verbose_name_plural': 'Categories', 34 | }, 35 | ), 36 | migrations.CreateModel( 37 | name='TutorialSeries', 38 | fields=[ 39 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 40 | ('tutorial_series', models.CharField(max_length=200)), 41 | ('series_summary', models.CharField(max_length=200)), 42 | ('tutorial_category', models.ForeignKey(default=1, on_delete=django.db.models.deletion.SET_DEFAULT, to='rest.tutorialcategory', verbose_name='Category')), 43 | ], 44 | options={ 45 | 'verbose_name_plural': 'Series', 46 | }, 47 | ), 48 | migrations.DeleteModel( 49 | name='Book', 50 | ), 51 | migrations.DeleteModel( 52 | name='Hero', 53 | ), 54 | migrations.AddField( 55 | model_name='tutorial', 56 | name='tutorial_series', 57 | field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.SET_DEFAULT, to='rest.tutorialseries', verbose_name='Series'), 58 | ), 59 | ] 60 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/0004_auto_20201207_0257.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.1.4 on 2020-12-07 02:57 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('rest', '0003_auto_20201207_0231'), 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Book', 16 | fields=[ 17 | ('book_id', models.AutoField(primary_key=True, serialize=False)), 18 | ('author', models.CharField(max_length=50)), 19 | ('title', models.CharField(max_length=200)), 20 | ('isbn', models.CharField(max_length=40)), 21 | ('release_date', models.DateField(null=True)), 22 | ], 23 | options={ 24 | 'verbose_name_plural': 'Books', 25 | }, 26 | ), 27 | migrations.CreateModel( 28 | name='Register', 29 | fields=[ 30 | ('user_id', models.AutoField(primary_key=True, serialize=False)), 31 | ('user_name', models.CharField(max_length=200)), 32 | ('user_password', models.CharField(max_length=200)), 33 | ], 34 | options={ 35 | 'verbose_name_plural': 'Registers', 36 | }, 37 | ), 38 | migrations.CreateModel( 39 | name='Store', 40 | fields=[ 41 | ('store_id', models.AutoField(primary_key=True, serialize=False)), 42 | ('store_name', models.CharField(max_length=150)), 43 | ], 44 | options={ 45 | 'verbose_name_plural': 'Stores', 46 | }, 47 | ), 48 | migrations.RemoveField( 49 | model_name='tutorialseries', 50 | name='tutorial_category', 51 | ), 52 | migrations.DeleteModel( 53 | name='Tutorial', 54 | ), 55 | migrations.DeleteModel( 56 | name='TutorialCategory', 57 | ), 58 | migrations.DeleteModel( 59 | name='TutorialSeries', 60 | ), 61 | migrations.AddField( 62 | model_name='book', 63 | name='store_id', 64 | field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.SET_DEFAULT, to='rest.store', verbose_name='Store'), 65 | ), 66 | ] 67 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/0005_auto_20201207_0325.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.1.4 on 2020-12-07 03:25 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('rest', '0004_auto_20201207_0257'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='book', 15 | name='isbn', 16 | field=models.CharField(max_length=40, unique=True), 17 | ), 18 | migrations.AlterField( 19 | model_name='register', 20 | name='user_name', 21 | field=models.CharField(max_length=200, unique=True), 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/__init__.py -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/__pycache__/0001_initial.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/__pycache__/0001_initial.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/__pycache__/0002_book.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/__pycache__/0002_book.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/__pycache__/0003_auto_20201207_0231.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/__pycache__/0003_auto_20201207_0231.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/__pycache__/0004_auto_20201207_0257.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/__pycache__/0004_auto_20201207_0257.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/__pycache__/0005_auto_20201207_0325.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/__pycache__/0005_auto_20201207_0325.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON-DJANGO-REST-FRAMEWORK/rest/migrations/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | class Store(models.Model): 3 | 4 | store_id = models.AutoField(primary_key=True) 5 | store_name = models.CharField(max_length=150) 6 | class Meta: 7 | # Gives the proper plural name for admin 8 | verbose_name_plural = "Stores" 9 | 10 | def __str__(self): 11 | return self.store_name 12 | 13 | class Register(models.Model): 14 | 15 | user_id = models.AutoField(primary_key=True) 16 | user_name = models.CharField(max_length=200, unique = True) 17 | user_password = models.CharField(max_length=200) 18 | class Meta: 19 | # Gives the proper plural name for admin 20 | verbose_name_plural = "Registers" 21 | 22 | def __str__(self): 23 | return self.user_name 24 | 25 | class Book(models.Model): 26 | book_id = models.AutoField(primary_key=True) 27 | store_id = models.ForeignKey(Store, default=1, verbose_name="Store", on_delete=models.SET_DEFAULT) 28 | author = models.CharField(max_length=50) 29 | title = models.CharField(max_length=200) 30 | isbn = models.CharField(max_length=40, unique = True) 31 | release_date = models.DateField(null = True) 32 | 33 | class Meta: 34 | # otherwise we get "Tutorial Seriess in admin" 35 | verbose_name_plural = "Books" 36 | 37 | def __str__(self): 38 | return self.title 39 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/serializers.py: -------------------------------------------------------------------------------- 1 | from rest_framework import serializers 2 | 3 | from .models import Register, Store, Book 4 | 5 | class BookSerializer(serializers.HyperlinkedModelSerializer): 6 | class Meta: 7 | model = Book 8 | fields = ('store_id', 'title', 'author', 'isbn', 'release_date') 9 | 10 | class StoreSerializer(serializers.HyperlinkedModelSerializer): 11 | class Meta: 12 | model = Store 13 | fields = ('store_id', 'store_name') 14 | 15 | class RegisterSerializer(serializers.HyperlinkedModelSerializer): 16 | class Meta: 17 | model = Register 18 | fields = ('user_id', 'user_name') 19 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import include, path 2 | from rest_framework import routers 3 | from . import views 4 | 5 | router = routers.DefaultRouter() 6 | router.register(r'books', views.BookViewSet) 7 | router.register(r'stores', views.StoreViewSet) 8 | router.register(r'registers', views.RegisterViewSet) 9 | 10 | # Wire up our API using automatic URL routing. 11 | # Additionally, we include login URLs for the browsable API. 12 | urlpatterns = [ 13 | path('', include(router.urls)), 14 | path('api-auth/', include('rest_framework.urls', namespace='rest_framework')) 15 | ] 16 | -------------------------------------------------------------------------------- /PYTHON-DJANGO-REST-FRAMEWORK/rest/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | from rest_framework import viewsets 5 | 6 | from .serializers import BookSerializer, StoreSerializer, RegisterSerializer 7 | from .models import Book, Store, Register 8 | 9 | 10 | class BookViewSet(viewsets.ModelViewSet): 11 | queryset = Book.objects.all().order_by('title') 12 | serializer_class = BookSerializer 13 | 14 | class StoreViewSet(viewsets.ModelViewSet): 15 | queryset = Store.objects.all().order_by('store_name') 16 | serializer_class = StoreSerializer 17 | 18 | class RegisterViewSet(viewsets.ModelViewSet): 19 | queryset = Register.objects.all().order_by('user_name') 20 | serializer_class = RegisterSerializer 21 | -------------------------------------------------------------------------------- /PYTHON/app.py: -------------------------------------------------------------------------------- 1 | #author: Sapan Kumar Mohanty 2 | #twitter: @htngapi 3 | from flask import Flask 4 | from flask_restful import Api 5 | from flask_jwt import JWT 6 | 7 | from security import authenticate, identity 8 | from resources.user import UserRegister 9 | from resources.book import Book, BookList 10 | from resources.store import Store, StoreList 11 | 12 | app = Flask(__name__) 13 | app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///data.db' 14 | app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True 15 | app.config['PROPAGATE_EXCEPTIONS'] = True 16 | app.secret_key = 'SapanCrackle' 17 | api = Api(app) 18 | 19 | 20 | @app.before_first_request 21 | def create_tables(): 22 | db.create_all() 23 | 24 | 25 | jwt = JWT(app, authenticate, identity) # /auth 26 | 27 | api.add_resource(Store, '/store/') 28 | api.add_resource(StoreList, '/stores') 29 | api.add_resource(Book, '/book/') 30 | api.add_resource(BookList, '/books') 31 | api.add_resource(UserRegister, '/register') 32 | 33 | if __name__ == '__main__': 34 | from db import db 35 | db.init_app(app) 36 | app.run(port=5000, debug=True) 37 | -------------------------------------------------------------------------------- /PYTHON/auth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON/auth.png -------------------------------------------------------------------------------- /PYTHON/data.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON/data.db -------------------------------------------------------------------------------- /PYTHON/data_old.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON/data_old.db -------------------------------------------------------------------------------- /PYTHON/db.py: -------------------------------------------------------------------------------- 1 | from flask_sqlalchemy import SQLAlchemy 2 | 3 | db = SQLAlchemy() 4 | -------------------------------------------------------------------------------- /PYTHON/images/Build REST api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON/images/Build REST api.png -------------------------------------------------------------------------------- /PYTHON/images/get-books.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON/images/get-books.png -------------------------------------------------------------------------------- /PYTHON/images/list-of-endpoints.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON/images/list-of-endpoints.png -------------------------------------------------------------------------------- /PYTHON/models/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /PYTHON/models/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON/models/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON/models/__pycache__/book.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON/models/__pycache__/book.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON/models/__pycache__/item.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON/models/__pycache__/item.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON/models/__pycache__/store.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON/models/__pycache__/store.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON/models/__pycache__/user.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON/models/__pycache__/user.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON/models/book.py: -------------------------------------------------------------------------------- 1 | from db import db 2 | 3 | 4 | class BookModel(db.Model): 5 | __tablename__ = 'books' 6 | 7 | id = db.Column(db.Integer, primary_key=True) 8 | title = db.Column(db.String(80)) 9 | author = db.Column(db.String(80)) 10 | isbn = db.Column(db.String(40)) 11 | release_date = db.Column(db.String(10)) 12 | price = db.Column(db.Float(precision=2)) 13 | store_id = db.Column(db.Integer, db.ForeignKey('stores.id')) 14 | store = db.relationship('StoreModel') 15 | 16 | def __init__(self, title, price, store_id, author, isbn, release_date): 17 | self.title = title 18 | self.price = price 19 | self.store_id = store_id 20 | self.author = author 21 | self.isbn = isbn 22 | self.release_date = release_date 23 | 24 | def json(self): 25 | return {'title': self.title, 'price': self.price, 'author': self.author, 'isbn': self.isbn, 'release_date': self.release_date} 26 | 27 | @classmethod 28 | def find_by_title(cls, title): 29 | return cls.query.filter_by(title=title).first() 30 | 31 | def save_to_db(self): 32 | db.session.add(self) 33 | db.session.commit() 34 | 35 | def delete_from_db(self): 36 | db.session.delete(self) 37 | db.session.commit() 38 | -------------------------------------------------------------------------------- /PYTHON/models/store.py: -------------------------------------------------------------------------------- 1 | from db import db 2 | 3 | 4 | class StoreModel(db.Model): 5 | __tablename__ = 'stores' 6 | 7 | id = db.Column(db.Integer, primary_key=True) 8 | name = db.Column(db.String(80)) 9 | 10 | books = db.relationship('BookModel', lazy='dynamic') 11 | 12 | def __init__(self, name): 13 | self.name = name 14 | 15 | def json(self): 16 | return {'name': self.name, 'books': [book.json() for book in self.books.all()]} 17 | 18 | @classmethod 19 | def find_by_name(cls, name): 20 | return cls.query.filter_by(name=name).first() 21 | 22 | def save_to_db(self): 23 | db.session.add(self) 24 | db.session.commit() 25 | 26 | def delete_from_db(self): 27 | db.session.delete(self) 28 | db.session.commit() 29 | -------------------------------------------------------------------------------- /PYTHON/models/user.py: -------------------------------------------------------------------------------- 1 | from db import db 2 | 3 | 4 | class UserModel(db.Model): 5 | __tablename__ = 'users' 6 | 7 | id = db.Column(db.Integer, primary_key=True) 8 | username = db.Column(db.String(80)) 9 | password = db.Column(db.String(80)) 10 | 11 | def __init__(self, username, password): 12 | self.username = username 13 | self.password = password 14 | 15 | def save_to_db(self): 16 | db.session.add(self) 17 | db.session.commit() 18 | 19 | @classmethod 20 | def find_by_username(cls, username): 21 | return cls.query.filter_by(username=username).first() 22 | 23 | @classmethod 24 | def find_by_id(cls, _id): 25 | return cls.query.filter_by(id=_id).first() 26 | -------------------------------------------------------------------------------- /PYTHON/readme.md: -------------------------------------------------------------------------------- 1 | ## PYTHON API Tutorial: REST API - CURD with PYTHON, Flask, Flask-JWT, Flask-RESTful, Flask-SQLALCHEMY, SQLLITE EXAMPLES 2 | 3 | ![REST API PYTHON FLASK JWT](https://github.com/TravelXML/Create-API-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-REST-API/blob/main/PYTHON/images/Build%20REST%20api.png) 4 | 5 | 6 | Create a RESTful web service for a Library. The service must have the following API endpoints: 7 | 8 | (C)reate a new Book 9 | (R)ead existing Books 10 | (U)pdate an existing Book 11 | (D)elete an existing Book 12 | 13 | A Book entity has the following properties: 14 | 15 | Author (mandatory) 16 | Title (mandatory) 17 | ISBN (mandatory) 18 | Release Date 19 | 20 | # Implementation(s) 21 | 22 | #### Create a project folder as 'rest-api' 23 | 24 | Go to project folder >> 'rest-api' 25 | 26 | #### Setup virtualenv in this project folder: 27 | 28 | pip3.8 install virtualenv 29 | virtualenv venv --python=python3.8 30 | 31 | #### Activate Virtual Environment 32 | 33 | source venv/bin/activate - Mac / Linux 34 | venv\Scripts\activate.bat - Windows 35 | 36 | #### Install Required Libraries 37 | 38 | pip install Flask 39 | pip install Flask-JWT 40 | pip install Flask-RESTful 41 | pip install Flask-SQLALCHEMY 42 | 43 | #### [Download](https://github.com/TravelXML/Create-API-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-REST-API/tree/main/PYTHON) the code and drop in to project folder 'rest-api' 44 | 45 | #### API is ready to RUN 46 | 47 | python app.py 48 | 49 | #### Endpoint Lists 50 | ![What All REST API end points](https://github.com/TravelXML/Create-API-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-REST-API/blob/main/PYTHON/images/list-of-endpoints.png) 51 | 52 | #### How Requests and Responses Look Like? 53 | ![Request and Responses Look Like](https://github.com/TravelXML/Create-API-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-REST-API/blob/main/PYTHON/images/get-books.png) 54 | 55 | 56 | **Python Version: 3.8**
57 | 58 | **Auth :** Auth Token will create after sucessive excution of endpoint '{{url}}/auth'
59 | 60 | **Request :** All request should be JSON data, specifications are mentioned below
61 | 62 | **Response :** JSON data
63 | 64 | I hope instructions are good to set up this project in your local, Enjoy Coding :+1: 65 | 66 | ![Back to HOME](https://github.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples) 67 | 68 | #### For Help, you can reach 69 | ------------------------------- 70 | Skype: sapan.mohannty 71 | 72 | Twitter: https://twitter.com/htngapi 73 | 74 | Linkedin: https://www.linkedin.com/in/travel-technology-cto/ 75 | -------------------------------------------------------------------------------- /PYTHON/resources/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /PYTHON/resources/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON/resources/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON/resources/__pycache__/book.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON/resources/__pycache__/book.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON/resources/__pycache__/item.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON/resources/__pycache__/item.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON/resources/__pycache__/store.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON/resources/__pycache__/store.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON/resources/__pycache__/user.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/PYTHON/resources/__pycache__/user.cpython-38.pyc -------------------------------------------------------------------------------- /PYTHON/resources/book.py: -------------------------------------------------------------------------------- 1 | from flask_restful import Resource, reqparse 2 | from flask_jwt import jwt_required 3 | from models.book import BookModel 4 | 5 | 6 | class Book(Resource): 7 | parser = reqparse.RequestParser() 8 | parser.add_argument('price', 9 | type=float, 10 | required=True, 11 | help="This field cannot be left blank!" 12 | ) 13 | parser.add_argument('store_id', 14 | type=int, 15 | required=True, 16 | help="Every item needs a store_id." 17 | ) 18 | parser.add_argument('author', 19 | type=str, 20 | required=True, 21 | help="Every item needs a author." 22 | ) 23 | parser.add_argument('isbn', 24 | type=str, 25 | required=True, 26 | help="Every item needs a isbn." 27 | ) 28 | parser.add_argument('release_date', 29 | type=str, 30 | required=False 31 | ) 32 | 33 | @jwt_required() 34 | def get(self, title): 35 | book = BookModel.find_by_title(title) 36 | if book: 37 | return book.json() 38 | return {'message': 'book not found'}, 404 39 | 40 | def post(self, title): 41 | if BookModel.find_by_title(title): 42 | return {'message': "An book with title '{}' already exists.".format(title)}, 400 43 | 44 | data = Book.parser.parse_args() 45 | book = BookModel(title, **data) 46 | try: 47 | book.save_to_db() 48 | except: 49 | return {"message": "An error occurred inserting the book."}, 500 50 | 51 | return book.json(), 201 52 | 53 | def delete(self, title): 54 | book = BookModel.find_by_title(title) 55 | if book: 56 | book.delete_from_db() 57 | return {'message': 'Item deleted.'} 58 | return {'message': 'Item not found.'}, 404 59 | 60 | def put(self, title): 61 | data = Book.parser.parse_args() 62 | 63 | book = BookModel.find_by_title(title) 64 | 65 | if book: 66 | book.price = data['price'] 67 | else: 68 | book = BookModel(title, **data) 69 | 70 | book.save_to_db() 71 | 72 | return book.json() 73 | 74 | 75 | class BookList(Resource): 76 | def get(self): 77 | return {'books': list(map(lambda x: x.json(), BookModel.query.all()))} 78 | -------------------------------------------------------------------------------- /PYTHON/resources/store.py: -------------------------------------------------------------------------------- 1 | from flask_restful import Resource 2 | from models.store import StoreModel 3 | 4 | 5 | class Store(Resource): 6 | def get(self, name): 7 | store = StoreModel.find_by_name(name) 8 | if store: 9 | return store.json() 10 | return {'message': 'Store not found'}, 404 11 | 12 | def post(self, name): 13 | if StoreModel.find_by_name(name): 14 | return {'message': "A store with name '{}' already exists.".format(name)}, 400 15 | 16 | store = StoreModel(name) 17 | try: 18 | store.save_to_db() 19 | except: 20 | return {"message": "An error occurred creating the store."}, 500 21 | 22 | return store.json(), 201 23 | 24 | def delete(self, name): 25 | store = StoreModel.find_by_name(name) 26 | if store: 27 | store.delete_from_db() 28 | 29 | return {'message': 'Store deleted'} 30 | 31 | 32 | class StoreList(Resource): 33 | def get(self): 34 | return {'stores': list(map(lambda x: x.json(), StoreModel.query.all()))} 35 | -------------------------------------------------------------------------------- /PYTHON/resources/user.py: -------------------------------------------------------------------------------- 1 | from flask_restful import Resource, reqparse 2 | from models.user import UserModel 3 | 4 | 5 | class UserRegister(Resource): 6 | parser = reqparse.RequestParser() 7 | parser.add_argument('username', 8 | type=str, 9 | required=True, 10 | help="This field cannot be blank." 11 | ) 12 | parser.add_argument('password', 13 | type=str, 14 | required=True, 15 | help="This field cannot be blank." 16 | ) 17 | 18 | def post(self): 19 | data = UserRegister.parser.parse_args() 20 | 21 | if UserModel.find_by_username(data['username']): 22 | return {"message": "A user with that username already exists"}, 400 23 | 24 | user = UserModel(data['username'], data['password']) 25 | user.save_to_db() 26 | 27 | return {"message": "User created successfully."}, 201 28 | -------------------------------------------------------------------------------- /PYTHON/security.py: -------------------------------------------------------------------------------- 1 | from werkzeug.security import safe_str_cmp 2 | from models.user import UserModel 3 | 4 | 5 | def authenticate(username, password): 6 | user = UserModel.find_by_username(username) 7 | if user and safe_str_cmp(user.password, password): 8 | return user 9 | 10 | 11 | def identity(payload): 12 | user_id = payload['identity'] 13 | return UserModel.find_by_id(user_id) 14 | -------------------------------------------------------------------------------- /images/BUILD-REST-API-laravel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/BUILD-REST-API-laravel.jpg -------------------------------------------------------------------------------- /images/Build REST api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Build REST api.png -------------------------------------------------------------------------------- /images/Build-REST-API-USING-GO-MUX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Build-REST-API-USING-GO-MUX.png -------------------------------------------------------------------------------- /images/Create-REST-API-with-php-oops-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Create-REST-API-with-php-oops-1.png -------------------------------------------------------------------------------- /images/Create-REST-API-with-php-oops-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Create-REST-API-with-php-oops-10.png -------------------------------------------------------------------------------- /images/Create-REST-API-with-php-oops-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Create-REST-API-with-php-oops-2.png -------------------------------------------------------------------------------- /images/Create-REST-API-with-php-oops-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Create-REST-API-with-php-oops-3.png -------------------------------------------------------------------------------- /images/Create-REST-API-with-php-oops-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Create-REST-API-with-php-oops-4.png -------------------------------------------------------------------------------- /images/Create-REST-API-with-php-oops-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Create-REST-API-with-php-oops-5.png -------------------------------------------------------------------------------- /images/Create-REST-API-with-php-oops-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Create-REST-API-with-php-oops-6.png -------------------------------------------------------------------------------- /images/Create-REST-API-with-php-oops-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Create-REST-API-with-php-oops-7.png -------------------------------------------------------------------------------- /images/Create-REST-API-with-php-oops-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Create-REST-API-with-php-oops-8.png -------------------------------------------------------------------------------- /images/Create-REST-API-with-php-oops-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Create-REST-API-with-php-oops-9.png -------------------------------------------------------------------------------- /images/Django-REST-API.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Django-REST-API.png -------------------------------------------------------------------------------- /images/GO_GIN_MAiN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/GO_GIN_MAiN.png -------------------------------------------------------------------------------- /images/Go-installation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Go-installation.png -------------------------------------------------------------------------------- /images/Login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Login.png -------------------------------------------------------------------------------- /images/NodeJS-Express-Mysql-REST-API.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/NodeJS-Express-Mysql-REST-API.jpg -------------------------------------------------------------------------------- /images/NodeJS-test-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/NodeJS-test-1.png -------------------------------------------------------------------------------- /images/NodeJs-test-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/NodeJs-test-10.png -------------------------------------------------------------------------------- /images/NodeJs-test-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/NodeJs-test-2.png -------------------------------------------------------------------------------- /images/NodeJs-test-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/NodeJs-test-3.png -------------------------------------------------------------------------------- /images/NodeJs-test-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/NodeJs-test-4.png -------------------------------------------------------------------------------- /images/NodeJs-test-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/NodeJs-test-5.png -------------------------------------------------------------------------------- /images/NodeJs-test-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/NodeJs-test-6.png -------------------------------------------------------------------------------- /images/NodeJs-test-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/NodeJs-test-7.png -------------------------------------------------------------------------------- /images/NodeJs-test-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/NodeJs-test-8.png -------------------------------------------------------------------------------- /images/NodeJs-test-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/NodeJs-test-9.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-1.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-10.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-11.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-12.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-13.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-14.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-15.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-16.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-17.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-2.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-3.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-4.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-5.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-6.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-7.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-8.png -------------------------------------------------------------------------------- /images/Nodejs-Jwt-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-Jwt-9.png -------------------------------------------------------------------------------- /images/Nodejs-file-folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-file-folder.png -------------------------------------------------------------------------------- /images/Nodejs-server-up-browser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Nodejs-server-up-browser.png -------------------------------------------------------------------------------- /images/Property-create.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Property-create.png -------------------------------------------------------------------------------- /images/REST-API-WITH-PHP-MYSQL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/REST-API-WITH-PHP-MYSQL.png -------------------------------------------------------------------------------- /images/Register-keys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Register-keys.png -------------------------------------------------------------------------------- /images/Register.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/Register.png -------------------------------------------------------------------------------- /images/django-local-server-up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/django-local-server-up.png -------------------------------------------------------------------------------- /images/django-restframework-books.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/django-restframework-books.png -------------------------------------------------------------------------------- /images/django-restframework-stores.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/django-restframework-stores.png -------------------------------------------------------------------------------- /images/go-gin1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/go-gin1.png -------------------------------------------------------------------------------- /images/go-gin2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/go-gin2.png -------------------------------------------------------------------------------- /images/go-gin3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/go-gin3.png -------------------------------------------------------------------------------- /images/go-gin4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/go-gin4.png -------------------------------------------------------------------------------- /images/go-gin5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/go-gin5.png -------------------------------------------------------------------------------- /images/go-gin6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/go-gin6.png -------------------------------------------------------------------------------- /images/go-gin7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/go-gin7.png -------------------------------------------------------------------------------- /images/go-mux-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/go-mux-1.png -------------------------------------------------------------------------------- /images/go-mux-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/go-mux-2.png -------------------------------------------------------------------------------- /images/go-version.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/go-version.png -------------------------------------------------------------------------------- /images/go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/go.png -------------------------------------------------------------------------------- /images/laravel-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/laravel-1.png -------------------------------------------------------------------------------- /images/laravel-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/laravel-2.png -------------------------------------------------------------------------------- /images/login-keys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/login-keys.png -------------------------------------------------------------------------------- /images/node-server.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/node-server.png -------------------------------------------------------------------------------- /images/nodejs-server-up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/nodejs-server-up.png -------------------------------------------------------------------------------- /images/property-delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/property-delete.png -------------------------------------------------------------------------------- /images/property-fetch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/property-fetch.png -------------------------------------------------------------------------------- /images/property-update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/property-update.png -------------------------------------------------------------------------------- /images/token.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TravelXML/REST-API-WITH-PYTHON-PHP-NODEJS-GO-DJANGO-LARAVEL-LUMEN-Examples/59b5203c3a91fc36c2e00627529f9461bf727421/images/token.png --------------------------------------------------------------------------------