Compare commits
2 Commits
feature/in
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eac41bad5c | ||
|
|
25a4a2f5cd |
26
.github/workflows/todos.yml
vendored
Normal file
26
.github/workflows/todos.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
name: Sync TODOs with Issues
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync_todos:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
issues: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Sync TODOs
|
||||||
|
uses: Solo-Web-Works/TODO-Sync@v1
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
summary_file: TODO_SUMMARY.md
|
||||||
|
dry_run: false
|
||||||
|
commit: false
|
||||||
@@ -13,4 +13,4 @@ $env:DEBUG='playwright-a11y-dashboard:*'; npm start
|
|||||||
## Notes, issues, and tasks
|
## Notes, issues, and tasks
|
||||||
|
|
||||||
- [Initial Project Outline](Outline.md)
|
- [Initial Project Outline](Outline.md)
|
||||||
- [Project Task Board](https://git.keithsolomon.net/keith/Playwright-A11y-Dashboard/projects/1)
|
- [Project Task Board](https://git.keithsolomon.net/keith/Playwright-A11y-Dashboard/projects/2)
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
/**
|
|
||||||
* Utility functions for the application.
|
|
||||||
*/
|
|
||||||
|
|
||||||
const isValidDomain = (domain) => {
|
|
||||||
// Regular expression to validate a domain name
|
|
||||||
const domainRegex = /^(?!:\/\/)([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/;
|
|
||||||
return domainRegex.test(domain);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
isValidDomain
|
|
||||||
};
|
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const { supabase } = require('../auth');
|
const { supabase } = require('../auth');
|
||||||
const { isValidDomain } = require('../helpers/utils');
|
|
||||||
|
|
||||||
class SiteModel {
|
class SiteModel {
|
||||||
|
|
||||||
@@ -17,25 +16,11 @@ class SiteModel {
|
|||||||
*
|
*
|
||||||
* @returns {Promise<Object>} - The result of the insert operation.
|
* @returns {Promise<Object>} - The result of the insert operation.
|
||||||
*/
|
*/
|
||||||
async insert(domainName) {
|
async insert(name, domainName) {
|
||||||
// validate inputs
|
const { error } = await supabase.from(siteModel.tableName).insert({
|
||||||
if (!domainName) {
|
name: name,
|
||||||
throw new Error('Name and domain name are required to insert a site.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// validate domain name format
|
|
||||||
if (!isValidDomain(domainName)) {
|
|
||||||
throw new Error('Invalid domain name format.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if the domain name already exists
|
|
||||||
if (await this.getByDomainName(domainName).then(data => data.length !== 0)) {
|
|
||||||
throw new Error('Domain name already exists.');
|
|
||||||
}
|
|
||||||
|
|
||||||
const { data, error } = await supabase.from(SiteModel.tableName).insert({
|
|
||||||
domain_name: domainName,
|
domain_name: domainName,
|
||||||
}).select();
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('Error inserting site:', error);
|
console.error('Error inserting site:', error);
|
||||||
@@ -79,24 +64,6 @@ class SiteModel {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a site by its domain name.
|
|
||||||
*
|
|
||||||
* @param {string} domainName - The domain name of the site.
|
|
||||||
*
|
|
||||||
* @returns {Promise<Object>} - The site object.
|
|
||||||
*/
|
|
||||||
async getByDomainName(domainName) {
|
|
||||||
const { data, error } = await supabase.from(SiteModel.tableName).select('*').eq('domain_name', domainName);
|
|
||||||
|
|
||||||
if (error) {
|
|
||||||
console.error('Error fetching site by domain name:', error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = SiteModel;
|
module.exports = SiteModel;
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
--text-base: 1rem;
|
--text-base: 1rem;
|
||||||
--text-base--line-height: calc(1.5 / 1);
|
--text-base--line-height: calc(1.5 / 1);
|
||||||
--radius-sm: 0.25rem;
|
--radius-sm: 0.25rem;
|
||||||
|
--default-transition-duration: 150ms;
|
||||||
|
--default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
--default-font-family: var(--font-sans);
|
--default-font-family: var(--font-sans);
|
||||||
--default-mono-font-family: var(--font-mono);
|
--default-mono-font-family: var(--font-mono);
|
||||||
--color-primary: oklch(0.57 0.203362 257.1706);
|
--color-primary: oklch(0.57 0.203362 257.1706);
|
||||||
@@ -212,6 +214,9 @@
|
|||||||
.mb-4 {
|
.mb-4 {
|
||||||
margin-bottom: calc(var(--spacing) * 4);
|
margin-bottom: calc(var(--spacing) * 4);
|
||||||
}
|
}
|
||||||
|
.contents {
|
||||||
|
display: contents;
|
||||||
|
}
|
||||||
.flex {
|
.flex {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
@@ -227,6 +232,12 @@
|
|||||||
.w-full {
|
.w-full {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
.border-collapse {
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
.resize {
|
||||||
|
resize: both;
|
||||||
|
}
|
||||||
.items-center {
|
.items-center {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
@@ -246,6 +257,10 @@
|
|||||||
margin-inline-end: calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-x-reverse)));
|
margin-inline-end: calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-x-reverse)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.border {
|
||||||
|
border-style: var(--tw-border-style);
|
||||||
|
border-width: 1px;
|
||||||
|
}
|
||||||
.bg-gray-200 {
|
.bg-gray-200 {
|
||||||
background-color: var(--color-gray-200);
|
background-color: var(--color-gray-200);
|
||||||
}
|
}
|
||||||
@@ -273,6 +288,18 @@
|
|||||||
.text-white {
|
.text-white {
|
||||||
color: var(--color-white);
|
color: var(--color-white);
|
||||||
}
|
}
|
||||||
|
.underline {
|
||||||
|
text-decoration-line: underline;
|
||||||
|
}
|
||||||
|
.outline {
|
||||||
|
outline-style: var(--tw-outline-style);
|
||||||
|
outline-width: 1px;
|
||||||
|
}
|
||||||
|
.transition {
|
||||||
|
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter, display, visibility, content-visibility, overlay, pointer-events;
|
||||||
|
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
||||||
|
transition-duration: var(--tw-duration, var(--default-transition-duration));
|
||||||
|
}
|
||||||
.hover\:text-gray-400 {
|
.hover\:text-gray-400 {
|
||||||
&:hover {
|
&:hover {
|
||||||
@media (hover: hover) {
|
@media (hover: hover) {
|
||||||
@@ -394,10 +421,22 @@ hr {
|
|||||||
inherits: false;
|
inherits: false;
|
||||||
initial-value: 0;
|
initial-value: 0;
|
||||||
}
|
}
|
||||||
|
@property --tw-border-style {
|
||||||
|
syntax: "*";
|
||||||
|
inherits: false;
|
||||||
|
initial-value: solid;
|
||||||
|
}
|
||||||
|
@property --tw-outline-style {
|
||||||
|
syntax: "*";
|
||||||
|
inherits: false;
|
||||||
|
initial-value: solid;
|
||||||
|
}
|
||||||
@layer properties {
|
@layer properties {
|
||||||
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
|
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
|
||||||
*, ::before, ::after, ::backdrop {
|
*, ::before, ::after, ::backdrop {
|
||||||
--tw-space-x-reverse: 0;
|
--tw-space-x-reverse: 0;
|
||||||
|
--tw-border-style: solid;
|
||||||
|
--tw-outline-style: solid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,14 +21,8 @@ router.get('/', async function(req, res, next) {
|
|||||||
*/
|
*/
|
||||||
router.get('/:id', async function(req, res, next) {
|
router.get('/:id', async function(req, res, next) {
|
||||||
const siteId = req.params.id;
|
const siteId = req.params.id;
|
||||||
let site = null;
|
|
||||||
|
|
||||||
try {
|
const site = await siteModel.getById(siteId);
|
||||||
site = await siteModel.getById(siteId);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching site by ID:', error);
|
|
||||||
return res.status(400).send('Error fetching site: ' + error.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!site) {
|
if (!site) {
|
||||||
return res.status(404).send('Site not found');
|
return res.status(404).send('Site not found');
|
||||||
@@ -37,52 +31,22 @@ router.get('/:id', async function(req, res, next) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* GET site by domain name.
|
|
||||||
*
|
|
||||||
* Returns a specific site by its domain name in JSON format.
|
|
||||||
*/
|
|
||||||
router.get('/domain/:domain', async function(req, res, next) {
|
|
||||||
const domainName = req.params.domain;
|
|
||||||
let sites = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
sites = await siteModel.getByDomainName(domainName);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching site by domain name:', error);
|
|
||||||
return res.status(400).send('Error fetching site: ' + error.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Site found:', sites);
|
|
||||||
|
|
||||||
if (!sites || sites.length === 0) {
|
|
||||||
return res.status(404).send('Site not found');
|
|
||||||
} else {
|
|
||||||
res.json(sites[0]); // Return the first match
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST create a new site.
|
* POST create a new site.
|
||||||
*
|
*
|
||||||
* Creates a new site with the provided domain name.
|
* Creates a new site with the provided domain name.
|
||||||
*
|
*
|
||||||
|
* // TODO: Implement validation for domain name format
|
||||||
|
* // TODO: Implement error handling for duplicate domains
|
||||||
* // TODO: Ability to add additional site properties (e.g., name, description)
|
* // TODO: Ability to add additional site properties (e.g., name, description)
|
||||||
*/
|
*/
|
||||||
router.post('/add', async function(req, res, next) {
|
router.post('/add/:domain', function(req, res, next) {
|
||||||
const domain = req.body.domain;
|
const domain = req.params.domain;
|
||||||
let newSite = null;
|
|
||||||
|
const newSite = siteModel.insert(domain);
|
||||||
// insert method passes a lot of validation errors to the caller
|
|
||||||
try {
|
|
||||||
newSite = await siteModel.insert(domain);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error creating site:', error);
|
|
||||||
return res.status(400).send('Error creating site: ' + error.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!newSite) {
|
if (!newSite) {
|
||||||
res.status(400).send('Error creating site');
|
return res.status(400).send('Error creating site');
|
||||||
} else {
|
} else {
|
||||||
res.status(201).json(newSite);
|
res.status(201).json(newSite);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<% for (let i = 0; i < sites.length; i++) { %>
|
<% for (let i = 0; i < sites.length; i++) { %>
|
||||||
<li><%= sites[i].domain_name %></li>
|
<li><%= sites[i].name %></li>
|
||||||
<% } %>
|
<% } %>
|
||||||
</ul>
|
</ul>
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
Reference in New Issue
Block a user