Skip to content

Commit 3302ae2

Browse files
authored
Merge pull request #2 from fac31/server-setup
Server setup
2 parents 18d90b6 + c44b217 commit 3302ae2

File tree

12 files changed

+81
-490
lines changed

12 files changed

+81
-490
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ how to get started
1010
`pnpm start`
1111

1212
`pnpm test`
13+
14+
`pnpm run test`

eslint.config.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ export default [
1212
},
1313
},
1414
{ files: ["**/*.js"], languageOptions: { sourceType: "commonjs" } },
15-
{ languageOptions: { globals: { ...globals.browser, ...globals.node } } },
15+
{
16+
languageOptions: {
17+
ecmaVersion: 2015,
18+
sourceType: "script",
19+
globals: { ...globals.browser, ...globals.node },
20+
},
21+
},
1622
pluginJs.configs.recommended,
1723
];

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"test": "playwright test",
8-
"start": "browser-sync start --server --files 'src/**/*' --no-notify --no-open --no-ui --port 3000",
9-
"dev": "nodemon"
7+
"test": "pnpm exec playwright test",
8+
"start": "node server.js",
9+
"dev": "nodemon server.js"
1010
},
1111
"keywords": [],
1212
"author": "",
1313
"license": "ISC",
1414
"dependencies": {
15+
"dotenv": "^16.4.5",
1516
"express": "^4.19.2"
1617
},
1718
"devDependencies": {

playwright.config.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// @ts-check
2-
const { defineConfig, devices } = require('@playwright/test');
2+
const { defineConfig, devices } = require("@playwright/test");
33

44
/**
55
* Read environment variables from file.
66
* https://github.com/motdotla/dotenv
77
*/
8-
// require('dotenv').config();
8+
require("dotenv").config();
99

1010
/**
1111
* @see https://playwright.dev/docs/test-configuration
1212
*/
1313
module.exports = defineConfig({
14-
testDir: './tests',
14+
testDir: "./tests",
1515
/* Run tests in files in parallel */
1616
fullyParallel: true,
1717
/* Fail the build on CI if you accidentally left test.only in the source code. */
@@ -21,31 +21,31 @@ module.exports = defineConfig({
2121
/* Opt out of parallel tests on CI. */
2222
workers: process.env.CI ? 1 : undefined,
2323
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
24-
reporter: 'html',
24+
reporter: "html",
2525
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
2626
use: {
2727
/* Base URL to use in actions like `await page.goto('/')`. */
28-
// baseURL: 'http://127.0.0.1:3000',
28+
baseURL: 'http://localhost:3000',
2929

3030
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
31-
trace: 'on-first-retry',
31+
trace: "on-first-retry",
3232
},
3333

3434
/* Configure projects for major browsers */
3535
projects: [
3636
{
37-
name: 'chromium',
38-
use: { ...devices['Desktop Chrome'] },
37+
name: "chromium",
38+
use: { ...devices["Desktop Chrome"] },
3939
},
4040

4141
{
42-
name: 'firefox',
43-
use: { ...devices['Desktop Firefox'] },
42+
name: "firefox",
43+
use: { ...devices["Desktop Firefox"] },
4444
},
4545

4646
{
47-
name: 'webkit',
48-
use: { ...devices['Desktop Safari'] },
47+
name: "webkit",
48+
use: { ...devices["Desktop Safari"] },
4949
},
5050

5151
/* Test against mobile viewports. */
@@ -70,10 +70,10 @@ module.exports = defineConfig({
7070
],
7171

7272
/* Run your local dev server before starting the tests */
73-
// webServer: {
74-
// command: 'npm run start',
75-
// url: 'http://127.0.0.1:3000',
76-
// reuseExistingServer: !process.env.CI,
77-
// },
73+
webServer: {
74+
command: "pnpm run start",
75+
url: "http://127.0.0.1:3000",
76+
reuseExistingServer: !process.env.CI,
77+
timeout: 120 * 1000,
78+
},
7879
});
79-

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/CSS/styles.css

Whitespace-only changes.

public/JS/index.js

Whitespace-only changes.

public/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<link rel="stylesheet" href="/public/CSS/styles.css" />
7+
<title>api project</title>
8+
</head>
9+
<body>
10+
<h1>Hello World!!!</h1>
11+
12+
13+
<script src="/public/JS/index.js"></script>
14+
</body>
15+
</html>

server.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const express = require("express");
2+
const path = require("path");
3+
require("dotenv").config();
4+
5+
const app = express();
6+
const PORT = process.env.PORT || 3000;
7+
8+
app.disable("x-powered-by");
9+
app.enable("trust proxy");
10+
11+
// Middleware
12+
app.use(express.static(path.join(__dirname, "public")));
13+
app.use(express.json());
14+
15+
app.get('/', (req, res) => {
16+
// res.status(200).sendFile(path.join(__dirname, "public", "index.html"));
17+
res.status(200).send("Hello World");
18+
});
19+
20+
app.listen(PORT, () =>
21+
console.log(`Server running on port http://localhost:${PORT}`)
22+
);

0 commit comments

Comments
 (0)