Skip to content

jwt rest api using realworld spec and google apps script

License

Notifications You must be signed in to change notification settings

lastlink/realworld-apps-script

Repository files navigation

RealWorld Google Apps Script Example App using gs RealWorld example app (WIP)

Description

Getting Started

  • npm install install dependencies

  • copy src\server\config.template.js to src\server\config.js

    • change the jwt encryption key and also give the id to the google script you're going to link it to
  • npx clasp login Log in to Google clasp and authorize with your Google account. Open the link and authorize.

  • Setup database and deploy location (options)

    1. npx clasp create --type sheets --title "RealWorld Apps Script Project" --rootDir ./dist Create a new Google Script bound to a Google Sheet (or set the type as standalone to create a standalone script in your Google Drive). Follow prompts in cmd to setup. May need to run this 2x and delete first document created after following the prompts.
    • Linked scripts file will be located in .clasp.json
    1. Copy template
    • Tools > Script Editor > copy the script id into from the url .claps.json

Deploy

  • npm run deploy
  • npm run deploy:prod Deploy the project (production mode)
  • faster development
    • npm run watch can auto build webpack files for dev mode for faster development cycle
    • npm run upload manually upload dist files

Proxy

  • see ref

    • proxy allows cors issues to be resolved while in browser
    • also DELETE and PUT requests will be forced to POST requests
    • besides content-type in POST request doesn't support headers, proxy will accept Authorization: Token {{token}} and will forward in post body
  • run simple server

    • cd proxy
    • php -S localhost:8000
    • open http://localhost:8000/

Development vs Production mode

In the production mode, the function names and variable names are shrinked and the output code is auto-minifed. The production mode is not recommended for testing and debugging the Apps Script code.

The .claspignore file

The .claspignore file allows you to specify file and directories that you do not wish to not upload to your Google Apps Script project via clasp push.

The default .claspignore file of the Apps Script Starter kit will push all the JS and HTML inside the rootDir folder and ignore all the other files.