Local skygear server static and lambda function testing questions


#1

I’ve setup local skygear server according to the doc below.
https://docs.skygear.io/guides/advanced/server/

Cloud functions work very well! However, I have 3 other questions.

  1. When I access localhost:3000/static, it shows an empty page. It shows Hello Word when I deployed to skygear cloud.
    I am runing skygear-server-darwin-amd64 and ./node_modules/.bin/skygear-node. Is there any other settings missing?
  2. Is it possible to do hot-reloading for skygear-node currently?
    UPDATE: Saw this just now! (https://github.com/SkygearIO/features/issues/170)
  3. Is it possible to do unit test on lambda functions if we are not using HTTP endpoint cloud functions?

Environment:
export DATABASE_URL=“postgresql://charles:@localhost/charles?sslmode=disable”
export API_KEY="[masked]"
export MASTER_KEY="[masked]"
export APP_NAME=“exampleapp”
export TOKEN_STORE=“jwt”
export TOKEN_STORE_SECRET="[masked]"
export PLUGINS=“JS1”
export JS1_TRANSPORT=“http”
export JS1_PATH=“http://localhost:9000”
export PUBSUB_URL=“ws://localhost:3000/pubsub”
export SKYGEAR_ENDPOINT=“http://localhost:3000”
export HTTP=“true”
export DEV_MODE=true
export ASSET_STORE=fs
export ASSET_STORE_SECRET=asset-secret
export ASSET_STORE_URL_PREFIX=http://127.0.0.1:3000/files
export ASSET_STORE_URL_EXPIRE_DURATION=3600


#2

@charleswong28

For 1st question, try to set SERVE_STATIC_ASSETS="true" for skygear-node?

For 2nd question and 3rd question, there are feature issues on that.

Maybe @david90 can revert on our best practices for 3 before we complete the feature issue?


#3

Thanks @bencheng!

Tried with SERVE_STATIC_ASSETS=“true” for skygear-node but still blank.

Log:

DEBU[0130] GET /static/                                  logger=router
DEBU[0130] ------ Header: ------                         logger=router
DEBU[0130] Cache-Control: [max-age=0]                    logger=router
DEBU[0130] User-Agent: [Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36]  logger=router
DEBU[0130] Accept-Encoding: [gzip, deflate, br]          logger=router
DEBU[0130] Accept-Language: [de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7]  logger=router
DEBU[0130] Cookie: [_ga=GA1.1.346256094.1514140291; locale=en; guest_token=[masked]; _session_id=[masked]; _ceg.s=p7zoxj; _ceg.u=p7zoxj]  logger=router
DEBU[0130] Connection: [keep-alive]                      logger=router
DEBU[0130] Upgrade-Insecure-Requests: [1]                logger=router
DEBU[0130] Accept: [text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8]  logger=router
DEBU[0130] ------ Request: ------                        logger=router
DEBU[0130] 0 bytes of request body                       logger=router
DEBU[0130] Matched params: []                            logger=router
DEBU[0130] ------ Response: ------                       logger=router
DEBU[0130] 0 bytes of response body                      logger=router

#4

Are your content put inside public_html instead of static ?


#5

@david90 Yes, it’s in /public_html/index.html

index.html:

<p>Hello World!</p>