Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: default prettier format for starters #4595

Merged
merged 1 commit into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions starters/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { nodeServerAdapter } from '@builder.io/qwik-city/adapters/node-server/vite';
import { extendConfig } from '@builder.io/qwik-city/vite';
import baseConfig from '../../vite.config';
import { nodeServerAdapter } from "@builder.io/qwik-city/adapters/node-server/vite";
import { extendConfig } from "@builder.io/qwik-city/vite";
import baseConfig from "../../vite.config";

export default extendConfig(baseConfig, () => {
return {
build: {
ssr: true,
rollupOptions: {
input: ['src/entry_aws-lambda.tsx', 'src/entry.ssr.tsx', '@qwik-city-plan'],
input: [
"src/entry_aws-lambda.tsx",
"src/entry.ssr.tsx",
"@qwik-city-plan",
],
},
},
plugins: [nodeServerAdapter({ name: 'express' })],
plugins: [nodeServerAdapter({ name: "express" })],
};
});
4 changes: 2 additions & 2 deletions starters/adapters/aws-lambda/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
service: qwik-lambda-app
frameworkVersion: '3'
frameworkVersion: "3"

provider:
name: aws
Expand All @@ -13,7 +13,7 @@ functions:
qwik:
handler: server/entry_aws-lambda.qwikApp
events:
- httpApi: '*'
- httpApi: "*"

custom:
serverless-offline:
Expand Down
27 changes: 15 additions & 12 deletions starters/adapters/aws-lambda/src/entry_aws-lambda.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
* - https://qwik.builder.io/docs/deployments/node/
*
*/
import 'source-map-support/register';
import { createQwikCity, type PlatformNode } from '@builder.io/qwik-city/middleware/node';
import qwikCityPlan from '@qwik-city-plan';
import { manifest } from '@qwik-client-manifest';
import serverlessExpress from '@vendia/serverless-express';
import render from './entry.ssr';
import express from 'express';
import { fileURLToPath } from 'node:url';
import { join } from 'node:path';
import "source-map-support/register";
import {
createQwikCity,
type PlatformNode,
} from "@builder.io/qwik-city/middleware/node";
import qwikCityPlan from "@qwik-city-plan";
import { manifest } from "@qwik-client-manifest";
import serverlessExpress from "@vendia/serverless-express";
import render from "./entry.ssr";
import express from "express";
import { fileURLToPath } from "node:url";
import { join } from "node:path";

declare global {
interface QwikCityPlatform extends PlatformNode {}
Expand All @@ -24,8 +27,8 @@ declare global {
// import compression from 'compression';

// Directories where the static assets are located
const distDir = join(fileURLToPath(import.meta.url), '..', '..', 'dist');
const buildDir = join(distDir, 'build');
const distDir = join(fileURLToPath(import.meta.url), "..", "..", "dist");
const buildDir = join(distDir, "build");

// Create the Qwik City Node middleware
const { router, notFound } = createQwikCity({ render, qwikCityPlan, manifest });
Expand All @@ -39,7 +42,7 @@ const app = express();

// Static asset handlers
// https://expressjs.com/en/starter/static-files.html
app.use(`/build`, express.static(buildDir, { immutable: true, maxAge: '1y' }));
app.use(`/build`, express.static(buildDir, { immutable: true, maxAge: "1y" }));
app.use(express.static(distDir, { redirect: false }));

// Use Qwik City's page and endpoint request handler
Expand Down
6 changes: 3 additions & 3 deletions starters/adapters/azure-swa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
2. If you're using github actions, make sure to add skip_api_build with true value.

```yml
app_location: '/'
api_location: 'azure-functions'
output_location: 'dist'
app_location: "/"
api_location: "azure-functions"
output_location: "dist"
skip_api_build: true # <--- add this line
###### End of Repository/Build Configurations ######
```
10 changes: 5 additions & 5 deletions starters/adapters/azure-swa/adapters/azure-swa/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { azureSwaAdapter } from '@builder.io/qwik-city/adapters/azure-swa/vite';
import { extendConfig } from '@builder.io/qwik-city/vite';
import baseConfig from '../../vite.config';
import { azureSwaAdapter } from "@builder.io/qwik-city/adapters/azure-swa/vite";
import { extendConfig } from "@builder.io/qwik-city/vite";
import baseConfig from "../../vite.config";

export default extendConfig(baseConfig, () => {
return {
build: {
ssr: true,
outDir: 'azure-functions/render',
outDir: "azure-functions/render",
rollupOptions: {
input: ['src/entry.azure-swa.tsx', '@qwik-city-plan'],
input: ["src/entry.azure-swa.tsx", "@qwik-city-plan"],
output: {
entryFileNames: `[name].[hash].mjs`,
chunkFileNames: `[name].[hash].mjs`,
Expand Down
11 changes: 7 additions & 4 deletions starters/adapters/azure-swa/src/entry.azure-swa.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
* - https://qwik.builder.io/docs/deployments/azure-swa/
*
*/
import { createQwikCity, type PlatformAzure } from '@builder.io/qwik-city/middleware/azure-swa';
import qwikCityPlan from '@qwik-city-plan';
import { manifest } from '@qwik-client-manifest';
import render from './entry.ssr';
import {
createQwikCity,
type PlatformAzure,
} from "@builder.io/qwik-city/middleware/azure-swa";
import qwikCityPlan from "@qwik-city-plan";
import { manifest } from "@qwik-client-manifest";
import render from "./entry.ssr";

declare global {
interface QwikCityPlatform extends PlatformAzure {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { cloudRunAdapter } from '@builder.io/qwik-city/adapters/cloud-run/vite';
import { extendConfig } from '@builder.io/qwik-city/vite';
import baseConfig from '../../vite.config';
import { cloudRunAdapter } from "@builder.io/qwik-city/adapters/cloud-run/vite";
import { extendConfig } from "@builder.io/qwik-city/vite";
import baseConfig from "../../vite.config";

export default extendConfig(baseConfig, () => {
return {
build: {
ssr: true,
rollupOptions: {
input: ['src/entry.cloud-run.tsx', '@qwik-city-plan'],
input: ["src/entry.cloud-run.tsx", "@qwik-city-plan"],
},
},
plugins: [cloudRunAdapter()],
Expand Down
51 changes: 27 additions & 24 deletions starters/adapters/cloud-run/src/entry.cloud-run.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@
* - https://qwik.builder.io/docs/deployments/gcp-cloud-run/
*
*/
import { createQwikCity, type PlatformNode } from '@builder.io/qwik-city/middleware/node';
import qwikCityPlan from '@qwik-city-plan';
import { manifest } from '@qwik-client-manifest';
import { createServer } from 'node:http';
import render from './entry.ssr';
import {
createQwikCity,
type PlatformNode,
} from "@builder.io/qwik-city/middleware/node";
import qwikCityPlan from "@qwik-city-plan";
import { manifest } from "@qwik-client-manifest";
import { createServer } from "node:http";
import render from "./entry.ssr";

declare global {
interface QwikCityPlatform extends PlatformNode {}
}

/** The default headers used by helmet */
const DEFAULT_HEADERS = {
'Content-Security-Policy': [
"Content-Security-Policy": [
`default-src 'self'`,
`base-uri 'self'`,
`font-src 'self' https: data:`,
Expand All @@ -31,19 +34,19 @@ const DEFAULT_HEADERS = {
`script-src-attr 'none'`,
`style-src 'self' https: 'unsafe-inline'`,
`upgrade-insecure-requests`,
].join(';'),
'Cross-Origin-Embedder-Policy': 'require-corp',
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Resource-Policy': 'same-origin',
'Origin-Agent-Cluster': '?1',
'Referrer-Policy': 'no-referrer',
'Strict-Transport-Security': 'max-age=15552000; includeSubDomains',
'X-Content-Type-Options': 'nosniff',
'X-DNS-Prefetch-Control': 'off',
'X-Download-Options': 'noopen',
'X-Frame-Options': 'SAMEORIGIN',
'X-Permitted-Cross-Domain-Policies': 'none',
'X-XSS-Protection': '0',
].join(";"),
"Cross-Origin-Embedder-Policy": "require-corp",
"Cross-Origin-Opener-Policy": "same-origin",
"Cross-Origin-Resource-Policy": "same-origin",
"Origin-Agent-Cluster": "?1",
"Referrer-Policy": "no-referrer",
"Strict-Transport-Security": "max-age=15552000; includeSubDomains",
"X-Content-Type-Options": "nosniff",
"X-DNS-Prefetch-Control": "off",
"X-Download-Options": "noopen",
"X-Frame-Options": "SAMEORIGIN",
"X-Permitted-Cross-Domain-Policies": "none",
"X-XSS-Protection": "0",
};

// Create the Qwik City router
Expand All @@ -52,13 +55,13 @@ const { router, notFound, staticFile } = createQwikCity({
qwikCityPlan,
manifest,
static: {
cacheControl: 'public, max-age=31557600',
cacheControl: "public, max-age=31557600",
},
getClientConn: (conn) => {
const xForwardedFor = conn.headers['x-forwarded-for'];
if (typeof xForwardedFor === 'string') {
const xForwardedFor = conn.headers["x-forwarded-for"];
if (typeof xForwardedFor === "string") {
return {
ip: xForwardedFor.split(',').shift()?.trim(),
ip: xForwardedFor.split(",").shift()?.trim(),
};
} else if (Array.isArray(xForwardedFor)) {
return {
Expand All @@ -73,7 +76,7 @@ const { router, notFound, staticFile } = createQwikCity({

const server = createServer();

server.on('request', (req, res) => {
server.on("request", (req, res) => {
for (const header of Object.entries(DEFAULT_HEADERS)) {
res.setHeader(...header);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { cloudflarePagesAdapter } from '@builder.io/qwik-city/adapters/cloudflare-pages/vite';
import { extendConfig } from '@builder.io/qwik-city/vite';
import baseConfig from '../../vite.config';
import { cloudflarePagesAdapter } from "@builder.io/qwik-city/adapters/cloudflare-pages/vite";
import { extendConfig } from "@builder.io/qwik-city/vite";
import baseConfig from "../../vite.config";

export default extendConfig(baseConfig, () => {
return {
build: {
ssr: true,
rollupOptions: {
input: ['src/entry.cloudflare-pages.tsx', '@qwik-city-plan'],
input: ["src/entry.cloudflare-pages.tsx", "@qwik-city-plan"],
},
},
plugins: [cloudflarePagesAdapter()],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import {
createQwikCity,
type PlatformCloudflarePages,
} from '@builder.io/qwik-city/middleware/cloudflare-pages';
import qwikCityPlan from '@qwik-city-plan';
import { manifest } from '@qwik-client-manifest';
import render from './entry.ssr';
} from "@builder.io/qwik-city/middleware/cloudflare-pages";
import qwikCityPlan from "@qwik-city-plan";
import { manifest } from "@qwik-client-manifest";
import render from "./entry.ssr";

declare global {
interface QwikCityPlatform extends PlatformCloudflarePages {}
Expand Down
12 changes: 6 additions & 6 deletions starters/adapters/deno/adapters/deno/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { denoServerAdapter } from '@builder.io/qwik-city/adapters/deno-server/vite';
import { extendConfig } from '@builder.io/qwik-city/vite';
import baseConfig from '../../vite.config';
import { denoServerAdapter } from "@builder.io/qwik-city/adapters/deno-server/vite";
import { extendConfig } from "@builder.io/qwik-city/vite";
import baseConfig from "../../vite.config";

export default extendConfig(baseConfig, () => {
return {
build: {
ssr: true,
rollupOptions: {
input: ['src/entry.deno.ts', '@qwik-city-plan'],
input: ["src/entry.deno.ts", "@qwik-city-plan"],
},
minify: false,
},
plugins: [
denoServerAdapter({
ssg: {
include: ['/*'],
origin: 'https://yoursite.dev',
include: ["/*"],
origin: "https://yoursite.dev",
},
}),
],
Expand Down
10 changes: 5 additions & 5 deletions starters/adapters/deno/src/entry.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
* - https://deno.com/manual/examples/http_server
*
*/
import { createQwikCity } from '@builder.io/qwik-city/middleware/deno';
import qwikCityPlan from '@qwik-city-plan';
import { manifest } from '@qwik-client-manifest';
import render from './entry.ssr';
import { createQwikCity } from "@builder.io/qwik-city/middleware/deno";
import qwikCityPlan from "@qwik-city-plan";
import { manifest } from "@qwik-client-manifest";
import render from "./entry.ssr";

// Create the Qwik City Deno middleware
const { router, notFound, staticFile } = createQwikCity({
Expand All @@ -21,7 +21,7 @@ const { router, notFound, staticFile } = createQwikCity({
});

// Allow for dynamic port
const port = Number(Deno.env.get('PORT') ?? 8080);
const port = Number(Deno.env.get("PORT") ?? 8080);

// Start the Deno server
const server = Deno.listen({ port });
Expand Down
10 changes: 5 additions & 5 deletions starters/adapters/express/adapters/express/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { nodeServerAdapter } from '@builder.io/qwik-city/adapters/node-server/vite';
import { extendConfig } from '@builder.io/qwik-city/vite';
import baseConfig from '../../vite.config';
import { nodeServerAdapter } from "@builder.io/qwik-city/adapters/node-server/vite";
import { extendConfig } from "@builder.io/qwik-city/vite";
import baseConfig from "../../vite.config";

export default extendConfig(baseConfig, () => {
return {
build: {
ssr: true,
rollupOptions: {
input: ['src/entry.express.tsx', '@qwik-city-plan'],
input: ["src/entry.express.tsx", "@qwik-city-plan"],
},
},
plugins: [nodeServerAdapter({ name: 'express' })],
plugins: [nodeServerAdapter({ name: "express" })],
};
});
23 changes: 13 additions & 10 deletions starters/adapters/express/src/entry.express.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
* - https://qwik.builder.io/docs/deployments/node/
*
*/
import { createQwikCity, type PlatformNode } from '@builder.io/qwik-city/middleware/node';
import qwikCityPlan from '@qwik-city-plan';
import { manifest } from '@qwik-client-manifest';
import render from './entry.ssr';
import express from 'express';
import { fileURLToPath } from 'node:url';
import { join } from 'node:path';
import {
createQwikCity,
type PlatformNode,
} from "@builder.io/qwik-city/middleware/node";
import qwikCityPlan from "@qwik-city-plan";
import { manifest } from "@qwik-client-manifest";
import render from "./entry.ssr";
import express from "express";
import { fileURLToPath } from "node:url";
import { join } from "node:path";

declare global {
interface QwikCityPlatform extends PlatformNode {}
Expand All @@ -22,8 +25,8 @@ declare global {
// import compression from 'compression';

// Directories where the static assets are located
const distDir = join(fileURLToPath(import.meta.url), '..', '..', 'dist');
const buildDir = join(distDir, 'build');
const distDir = join(fileURLToPath(import.meta.url), "..", "..", "dist");
const buildDir = join(distDir, "build");

// Allow for dynamic port
const PORT = process.env.PORT ?? 3000;
Expand All @@ -40,7 +43,7 @@ const app = express();

// Static asset handlers
// https://expressjs.com/en/starter/static-files.html
app.use(`/build`, express.static(buildDir, { immutable: true, maxAge: '1y' }));
app.use(`/build`, express.static(buildDir, { immutable: true, maxAge: "1y" }));
app.use(express.static(distDir, { redirect: false }));

// Use Qwik City's page and endpoint request handler
Expand Down