Skip to content

Replace deprecated builder#1

Open
paulogdm wants to merge 1 commit intowwwflorencio:masterfrom
paulogdm:patch-1
Open

Replace deprecated builder#1
paulogdm wants to merge 1 commit intowwwflorencio:masterfrom
paulogdm:patch-1

Conversation

@paulogdm
Copy link

@paulogdm paulogdm commented Dec 31, 2019

@now/node-server has been deprecated in favor of @now/node

@paulogdm
Copy link
Author

You can also remove a great portion of your configuration file from:

{
  "version": 2,
  "name": "djproducerbot",
  "alias": [
    "djproducerbot.now.sh"
  ],
  "public": true,
  "builds": [
    {
      "src": "index.js",
      "use": "@now/node-server",
      "config": {
        "includeFiles": [
          "binaries/**",
          "audios/**"
        ]
      }
    }
  ],
  "routes": [
    {
      "headers": {
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
        "Access-Control-Allow-Headers": "X-Requested-With, Content-Type, Accept"
      },
      "src": "/.*",
      "dest": "/index.js"
    }
  ]
}

to

{
  "name": "djproducerbot",
  "public": true,
  "functions": {
    "api/index.js": {
      "includeFiles": ["../binaries/**", "../audios/**"]
    }
  },
  "rewrites": [
    { "source": "/(.*)", "destination": "/api/index.js" },
  ]
  "headers": [
    {
      "headers": {
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
        "Access-Control-Allow-Headers": "X-Requested-With, Content-Type, Accept"
      },
      "source": "/.*"
    }
  ]
}

How:
1- "version": 2, this is already the default version of the platform.
2- "alias":[]: You can use https://zeit.co/docs/v2/custom-domains
3- "builds": [: You can use Zero Config and refactor your code a little bit. Just move your entrypoint to api/ and Now will understand your intention.
4- routes has been deprecated in favor of rewrites, redirects and headers: https://zeit.co/docs/configuration#project/redirects

@b3nab
Copy link

b3nab commented Jan 26, 2020

@paulogdm How to refactor the bot code to use Now v2.0 and the api serverless functions?
Do you have some examples to provide or a description about how to refactor the code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants