Laravel Forge JavaScript SDK

Nginx Templates

Nginx Templates

Create a Nginx template

Method

forge.nginxTemplates.create(server_id, payload)

Usage

1const forge = new Forge('API_TOKEN');
2
3const template = await forge.nginxTemplates.create(server_id, payload);

Payload

1{
2 name: 'My Nginx Template',
3 content: 'server { listen {{ PORT }}; location = / { ... } }'
4}

Payload Parameters

KeyDescription
nameThe name of the template.
contentThe content of the template.

Nginx templates support multiple variables that will be replaced with real data when the site is being created. For more information on variables, see the Nginx templates documentation.

Example Response

1{
2 "template": {
3 "id": 1,
4 "server_id": 50,
5 "name": "My Nginx Template",
6 "content": "server { listen {{ PORT }}; location = / { ... } }"
7 }
8}

List all Nginx templates

Method

forge.nginxTemplates.list(server_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3const templates = await forge.nginxTemplates.list(server_id);

Example Response

1{
2 "templates": [
3 {
4 "id": 1,
5 "server_id": 50,
6 "name": "My Nginx Template",
7 "content": "server { listen {{ PORT }}; location = / { ... } }"
8 }
9 ]
10}

Get the default Nginx template

When a site is created without a custom Nginx template selected, this is the Nginx configuration that Forge will use.

Method

forge.nginxTemplates.getDefault(server_id, template_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3const template = await forge.nginxTemplates.getDefault(server_id, template_id);

Example Response

1{
2 "template": {
3 "id": 1,
4 "server_id": 50,
5 "name": "Forge Default",
6 "content": "..."
7 }
8}

Get a Nginx template

Method

forge.nginxTemplates.get(server_id, template_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3const template = await forge.nginxTemplates.get(server_id, template_id);

Example Response

1{
2 "template": {
3 "id": 1,
4 "server_id": 50,
5 "name": "My Nginx Template",
6 "content": "server { listen {{ PORT }}; location = / { ... } }"
7 }
8}

Update a Nginx template

Method

forge.nginxTemplates.update(server_id, template_id, payload)

Usage

1const forge = new Forge('API_TOKEN');
2
3const template = await forge.nginxTemplates.update(
4 server_id,
5 template_id,
6 payload,
7);

Payload

1{
2 name: 'My Updated Nginx Template',
3 content: 'server { listen {{ PORT }}; location = / { ... } }'
4}

Payload Parameters

KeyDescription
nameThe name of the template.
contentThe content of the template.

Nginx templates support multiple variables that will be replaced with real data when the site is being created. For more information on variables, see the Nginx templates documentation.

Example Response

1{
2 "template": {
3 "id": 1,
4 "server_id": 50,
5 "name": "My Updated Nginx Template",
6 "content": "server { listen {{ PORT }}; location = / { ... } }"
7 }
8}

Delete a Nginx template

Method

forge.nginxTemplates.delete(server_id, template_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3await forge.nginxTemplates.delete(server_id, template_id);

Edit this page on GitHub