mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 00:49:02 +00:00
Merge branch 'feat-sites' into feat-screenshot-task
This commit is contained in:
commit
2ae61164d4
15 changed files with 110 additions and 18 deletions
|
|
@ -555,7 +555,7 @@ App::init()
|
|||
*/
|
||||
|
||||
App::init()
|
||||
->groups(['database', 'functions', 'messaging'])
|
||||
->groups(['database', 'functions', 'sites', 'messaging'])
|
||||
->inject('project')
|
||||
->inject('request')
|
||||
->action(function (Document $project, Request $request) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ class Get extends Base
|
|||
->setHttpPath('/v1/functions/templates/:templateId')
|
||||
->desc('Get function template')
|
||||
->label('scope', 'public')
|
||||
->groups(['api', 'functions'])
|
||||
->label('resourceType', RESOURCE_TYPE_FUNCTIONS)
|
||||
->label('sdk', new Method(
|
||||
namespace: 'functions',
|
||||
|
|
|
|||
|
|
@ -29,9 +29,8 @@ class XList extends Base
|
|||
$this
|
||||
->setHttpMethod(Action::HTTP_REQUEST_METHOD_GET)
|
||||
->setHttpPath('/v1/functions/templates')
|
||||
->desc('List function templates')
|
||||
->desc('List templates')
|
||||
->label('scope', 'public')
|
||||
->groups(['api', 'functions'])
|
||||
->label('resourceType', RESOURCE_TYPE_FUNCTIONS)
|
||||
->label('sdk', new Method(
|
||||
namespace: 'functions',
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ class Get extends Base
|
|||
->setHttpPath('/v1/sites/templates/:templateId')
|
||||
->desc('Get site template')
|
||||
->label('scope', 'public')
|
||||
->groups(['api', 'sites'])
|
||||
->label('sdk', new Method(
|
||||
namespace: 'sites',
|
||||
name: 'getTemplate',
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ class XList extends Base
|
|||
->setHttpPath('/v1/sites/templates')
|
||||
->desc('List templates')
|
||||
->label('scope', 'public')
|
||||
->groups(['api', 'sites'])
|
||||
->label('sdk', new Method(
|
||||
namespace: 'sites',
|
||||
name: 'listTemplates',
|
||||
|
|
|
|||
|
|
@ -82,6 +82,8 @@ trait ProjectCustom
|
|||
'sites.write',
|
||||
'execution.read',
|
||||
'execution.write',
|
||||
'log.read',
|
||||
'log.write',
|
||||
'locale.read',
|
||||
'avatars.read',
|
||||
'health.read',
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ class FunctionsCustomClientTest extends Scope
|
|||
*/
|
||||
// List all templates
|
||||
$templates = $this->client->call(Client::METHOD_GET, '/functions/templates', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'content-type' => 'application/json'
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(200, $templates['headers']['status-code']);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\E2E\Services\Functions;
|
||||
|
||||
use Appwrite\Functions\Specification;
|
||||
use Appwrite\Tests\Retry;
|
||||
use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
|
|
@ -511,6 +512,7 @@ class FunctionsCustomServerTest extends Scope
|
|||
/**
|
||||
* @depends testUpdateFunction
|
||||
*/
|
||||
#[Retry(count: 3)]
|
||||
public function testCancelDeploymentBuild($data): void
|
||||
{
|
||||
$functionId = $data['functionId'];
|
||||
|
|
|
|||
|
|
@ -208,12 +208,14 @@ trait SitesBase
|
|||
return $deployments;
|
||||
}
|
||||
|
||||
protected function listLogs(string $siteId, mixed $params = []): mixed
|
||||
protected function listLogs(string $siteId, array $queries = []): mixed
|
||||
{
|
||||
$logs = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId . '/logs', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), $params);
|
||||
], $this->getHeaders()), [
|
||||
'queries' => $queries
|
||||
]);
|
||||
|
||||
return $logs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\E2E\Services\Sites;
|
||||
|
||||
use Appwrite\Sites\Specification;
|
||||
use Appwrite\Tests\Retry;
|
||||
use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
|
|
@ -674,6 +675,7 @@ class SitesCustomServerTest extends Scope
|
|||
$this->cleanupSite($siteId);
|
||||
}
|
||||
|
||||
#[Retry(count: 3)]
|
||||
public function testCancelDeploymentBuild(): void
|
||||
{
|
||||
$siteId = $this->setupSite([
|
||||
|
|
@ -1675,4 +1677,74 @@ class SitesCustomServerTest extends Scope
|
|||
|
||||
$this->cleanupSite($siteId);
|
||||
}
|
||||
|
||||
public function testSSRLogs(): void
|
||||
{
|
||||
$siteId = $this->setupSite([
|
||||
'siteId' => ID::unique(),
|
||||
'name' => 'SSR site',
|
||||
'framework' => 'astro',
|
||||
'adapter' => 'ssr',
|
||||
'buildRuntime' => 'ssr-22',
|
||||
'outputDirectory' => './dist',
|
||||
'buildCommand' => 'npm run build',
|
||||
'installCommand' => 'npm install',
|
||||
'fallbackFile' => '',
|
||||
]);
|
||||
|
||||
$this->assertNotEmpty($siteId);
|
||||
|
||||
$domain = $this->setupSiteDomain($siteId);
|
||||
|
||||
$deploymentId = $this->setupDeployment($siteId, [
|
||||
'code' => $this->packageSite('astro'),
|
||||
'activate' => 'true'
|
||||
]);
|
||||
|
||||
$this->assertNotEmpty($deploymentId);
|
||||
|
||||
$domain = $this->getSiteDomain($siteId);
|
||||
$proxyClient = new Client();
|
||||
$proxyClient->setEndpoint('http://' . $domain);
|
||||
|
||||
$response = $proxyClient->call(Client::METHOD_GET, '/logs-inline');
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertStringContainsString("Inline logs printed.", $response['body']);
|
||||
|
||||
$logs = $this->listLogs($siteId, [
|
||||
Query::orderDesc('$createdAt')->toString(),
|
||||
Query::limit(1)->toString(),
|
||||
]);
|
||||
$this->assertEquals(200, $logs['headers']['status-code']);
|
||||
$this->assertStringContainsString("GET", $logs['body']['executions'][0]['requestMethod']);
|
||||
$this->assertStringContainsString("/logs-inline", $logs['body']['executions'][0]['requestPath']);
|
||||
$this->assertStringContainsString("Log1", $logs['body']['executions'][0]['logs']);
|
||||
$this->assertStringContainsString("Log2", $logs['body']['executions'][0]['logs']);
|
||||
$this->assertStringContainsString("Error1", $logs['body']['executions'][0]['errors']);
|
||||
$this->assertStringContainsString("Error2", $logs['body']['executions'][0]['errors']);
|
||||
$log1Id = $logs['body']['executions'][0]['$id'];
|
||||
$this->assertNotEmpty($log1Id);
|
||||
|
||||
$response = $proxyClient->call(Client::METHOD_GET, '/logs-action');
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertStringContainsString("Action logs printed.", $response['body']);
|
||||
|
||||
$logs = $this->listLogs($siteId, [
|
||||
Query::orderDesc('$createdAt')->toString(),
|
||||
Query::limit(1)->toString(),
|
||||
]);
|
||||
$this->assertEquals(200, $logs['headers']['status-code']);
|
||||
$this->assertStringContainsString("GET", $logs['body']['executions'][0]['requestMethod']);
|
||||
$this->assertStringContainsString("/logs-action", $logs['body']['executions'][0]['requestPath']);
|
||||
$this->assertStringContainsString("Log1", $logs['body']['executions'][0]['logs']);
|
||||
$this->assertStringContainsString("Log2", $logs['body']['executions'][0]['logs']);
|
||||
$this->assertStringContainsString("Error1", $logs['body']['executions'][0]['errors']);
|
||||
$this->assertStringContainsString("Error2", $logs['body']['executions'][0]['errors']);
|
||||
$log2Id = $logs['body']['executions'][0]['$id'];
|
||||
$this->assertNotEmpty($log2Id);
|
||||
|
||||
$this->assertNotEquals($log1Id, $log2Id);
|
||||
|
||||
$this->cleanupSite($siteId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import { defineConfig } from 'astro/config';
|
||||
import node from '@astrojs/node';
|
||||
import 'dotenv/config';
|
||||
|
||||
export default defineConfig({
|
||||
output: 'server',
|
||||
output: 'server',
|
||||
adapter: node({
|
||||
mode: 'standalone'
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@astrojs/node": "^9.0.2",
|
||||
"astro": "^5.2.5",
|
||||
"dotenv": "^16.4.7"
|
||||
"astro": "^5.2.5"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
7
tests/resources/sites/astro/src/pages/logs-action.js
Normal file
7
tests/resources/sites/astro/src/pages/logs-action.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export async function GET(context) {
|
||||
console.log("Log1");
|
||||
console.error("Error1");
|
||||
console.log("Log2");
|
||||
console.error("Error2");
|
||||
return new Response('Action logs printed.');
|
||||
}
|
||||
18
tests/resources/sites/astro/src/pages/logs-inline.astro
Normal file
18
tests/resources/sites/astro/src/pages/logs-inline.astro
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
console.log("Log1");
|
||||
console.error("Error1");
|
||||
console.log("Log2");
|
||||
console.error("Error2");
|
||||
---
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Astro Logs</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Inline logs printed.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"extends": "astro/tsconfigs/strict",
|
||||
"include": [".astro/types.d.ts", "**/*"],
|
||||
"exclude": ["dist"]
|
||||
}
|
||||
Loading…
Reference in a new issue