Install and use prettier
This commit is contained in:
@@ -32,7 +32,7 @@ Any static assets, like images, can be placed in the `public/` directory.
|
||||
All commands are run from the root of the project, from a terminal:
|
||||
|
||||
| Command | Action |
|
||||
|:----------------|:--------------------------------------------|
|
||||
| :-------------- | :------------------------------------------ |
|
||||
| `npm install` | Installs dependencies |
|
||||
| `npm run dev` | Starts local dev server at `localhost:3000` |
|
||||
| `npm run build` | Build your production site to `./dist/` |
|
||||
|
||||
@@ -5,14 +5,12 @@ export default {
|
||||
// public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing.
|
||||
buildOptions: {
|
||||
// site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
|
||||
sitemap: true, // Generate sitemap (set to "false" to disable)
|
||||
sitemap: true, // Generate sitemap (set to "false" to disable)
|
||||
},
|
||||
devOptions: {
|
||||
// hostname: 'localhost', // The hostname to run the dev server on.
|
||||
// port: 3000, // The port to run the dev server on.
|
||||
// tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
|
||||
},
|
||||
renderers: [
|
||||
"@astrojs/renderer-react"
|
||||
],
|
||||
renderers: ["@astrojs/renderer-react"],
|
||||
};
|
||||
|
||||
@@ -4,10 +4,15 @@
|
||||
}
|
||||
|
||||
:root {
|
||||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;
|
||||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial,
|
||||
sans-serif, Apple Color Emoji, Segoe UI Emoji;
|
||||
font-size: 1rem;
|
||||
--user-font-scale: 1rem - 16px;
|
||||
font-size: clamp(0.875rem, 0.4626rem + 1.0309vw + var(--user-font-scale), 1.125rem);
|
||||
font-size: clamp(
|
||||
0.875rem,
|
||||
0.4626rem + 1.0309vw + var(--user-font-scale),
|
||||
1.125rem
|
||||
);
|
||||
}
|
||||
|
||||
body {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
:root {
|
||||
--font-mono: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Liberation Mono',
|
||||
'Nimbus Mono L', Monaco, 'Courier New', Courier, monospace;
|
||||
--font-mono: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console",
|
||||
"Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono",
|
||||
"Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier,
|
||||
monospace;
|
||||
--color-light: #f3f4f6;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState } from 'react';
|
||||
import { useState } from "react";
|
||||
|
||||
export default function ReactCounter() {
|
||||
const [count, setCount] = useState(0);
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* Global Config
|
||||
*/
|
||||
|
||||
const config = {}
|
||||
const config = {};
|
||||
|
||||
// Domains
|
||||
config.domains = {}
|
||||
config.domains = {};
|
||||
|
||||
/**
|
||||
* API Domain
|
||||
@@ -13,6 +13,6 @@ config.domains = {}
|
||||
* This will enable your front-end to communicate with your back-end.
|
||||
* (e.g. 'https://api.mydomain.com' or 'https://091jafsl10.execute-api.us-east-1.amazonaws.com')
|
||||
*/
|
||||
config.domains.api = 'https://1t8da6s66e.execute-api.us-east-1.amazonaws.com'
|
||||
config.domains.api = "https://1t8da6s66e.execute-api.us-east-1.amazonaws.com";
|
||||
|
||||
export default config
|
||||
export default config;
|
||||
|
||||
@@ -2,70 +2,69 @@
|
||||
* Utils: Back-end
|
||||
*/
|
||||
|
||||
import config from '../config'
|
||||
import config from "../config";
|
||||
|
||||
/**
|
||||
* Register a new user
|
||||
*/
|
||||
export const userRegister = async (email, password) => {
|
||||
return await requestApi('/users/register', 'POST', { email, password })
|
||||
}
|
||||
return await requestApi("/users/register", "POST", { email, password });
|
||||
};
|
||||
|
||||
/**
|
||||
* Login a new user
|
||||
*/
|
||||
export const userLogin = async (email, password) => {
|
||||
return await requestApi('/users/login', 'POST', { email, password })
|
||||
}
|
||||
return await requestApi("/users/login", "POST", { email, password });
|
||||
};
|
||||
|
||||
/**
|
||||
* userGet
|
||||
*/
|
||||
export const userGet = async (token) => {
|
||||
return await requestApi('/user', 'POST', null, {
|
||||
Authorization: `Bearer ${token}`
|
||||
})
|
||||
}
|
||||
return await requestApi("/user", "POST", null, {
|
||||
Authorization: `Bearer ${token}`,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* API request to call the backend
|
||||
*/
|
||||
export const requestApi = async (
|
||||
path = '',
|
||||
method = 'GET',
|
||||
path = "",
|
||||
method = "GET",
|
||||
data = null,
|
||||
headers = {}) => {
|
||||
|
||||
headers = {}
|
||||
) => {
|
||||
// Check if API URL has been set
|
||||
if (!config?.domains?.api) {
|
||||
throw new Error(`Error: Missing API Domain – Please add the API domain from your serverless Express.js back-end to this front-end application. You can do this in the "site" folder, in the "./config.js" file. Instructions are listed there and in the documentation.`)
|
||||
throw new Error(
|
||||
`Error: Missing API Domain – Please add the API domain from your serverless Express.js back-end to this front-end application. You can do this in the "site" folder, in the "./config.js" file. Instructions are listed there and in the documentation.`
|
||||
);
|
||||
}
|
||||
|
||||
// Prepare URL
|
||||
if (!path.startsWith('/')) {
|
||||
path = `/${path}`
|
||||
if (!path.startsWith("/")) {
|
||||
path = `/${path}`;
|
||||
}
|
||||
const url = `${config.domains.api}${path}`
|
||||
const url = `${config.domains.api}${path}`;
|
||||
|
||||
// Set headers
|
||||
headers = Object.assign(
|
||||
{ 'Content-Type': 'application/json' },
|
||||
headers
|
||||
)
|
||||
headers = Object.assign({ "Content-Type": "application/json" }, headers);
|
||||
|
||||
// Default options are marked with *
|
||||
const response = await fetch(url, {
|
||||
method: method.toUpperCase(),
|
||||
mode: 'cors',
|
||||
cache: 'no-cache',
|
||||
mode: "cors",
|
||||
cache: "no-cache",
|
||||
headers,
|
||||
body: data ? JSON.stringify(data) : null
|
||||
})
|
||||
body: data ? JSON.stringify(data) : null,
|
||||
});
|
||||
|
||||
if (response.status < 200 || response.status >= 300) {
|
||||
const error = await response.json()
|
||||
throw new Error(error.error)
|
||||
const error = await response.json();
|
||||
throw new Error(error.error);
|
||||
}
|
||||
|
||||
return await response.json()
|
||||
}
|
||||
return await response.json();
|
||||
};
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from './api'
|
||||
export * from "./api";
|
||||
|
||||
Reference in New Issue
Block a user