This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Data { | |
id: number; | |
name: string; | |
} | |
// Abstraction layer representing a database | |
interface Database { | |
save(data: Data): void; | |
update(data: Data): void; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Interface segregation for user actions | |
interface UserActions { | |
login(): void; | |
logout(): void; | |
} | |
// Separate interfaces for specific actions | |
interface EmergencyContactable { | |
notifyEmergencyContact(message: string): void; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Abstract class representing a User | |
abstract class User { | |
// Abstract methods to be implemented by subclasses | |
abstract login(): void; | |
abstract logout(): void; | |
} | |
// Concrete subclass representing an AdminUser | |
class AdminUser extends User { | |
login(): void { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Interface defining the behavior of content items | |
interface Content { | |
displayContent(): void; | |
} | |
// Class for displaying text content | |
class TextContent implements Content { | |
constructor(private text: string) {} | |
displayContent(): void { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Class responsible for handling user authentication and authorization | |
class Authenticator { | |
public authenticateUser(username: string, password: string): boolean { | |
// Authentication logic | |
return true; | |
} | |
public authorizeUser(userRole: string): boolean { | |
// Authorization logic | |
return userRole === "admin"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pwa: { | |
manifest: { | |
// Define basic app information | |
name: "Rentals Nuxt App", // Name of the app | |
short_name: "Rentals App", // Short name of the app | |
description: "Rentals App built with Nuxt.js", // Description of the app | |
theme_color: "#3b82f6", // Theme color of the app | |
lang: "en", // Language of the app | |
background_color: "#3b82f6", // Background color of the app | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @type {import('next').NextConfig} */ | |
const withPWA = require("next-pwa")({ | |
dest: "public", // output directory | |
register: true, // register pwa | |
skipWaiting: true, // skip waiting for old service worker to be disabled | |
disable: process.env.NODE_ENV === "development", // disable in development | |
runtimeCaching: [ | |
//cache assets & data from external api | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "application name", // sets the name of the app | |
"short_name": "short name application", // sets a shorter name of the app | |
"theme_color": "#1976d2", // determines the primary color scheme used by the app | |
"background_color": "#fafafa", // sets the background color behind the app when it is launched | |
"display": "standalone", // determines how the app is displayed to users | |
"scope": "./", // specifies the base URL for the app and restricts its access to specific folders | |
"start_url": "./", // specifies the URL where the app should start when launched from the user's home screen or app launcher | |
"icons": [ // contains an array of objects specifying the icons used for the app | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="theme-color" content="#000000" /> | |
<meta name="description" content="Rentals App" /> | |
<meta name="author" content="Rental App" /> | |
<meta name="keywords" content="rental, app, rentals app" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { build, files } from '$service-worker'; | |
const worker = self; | |
const STATIC_CACHE_NAME = 'cache-v1'; | |
const APP_CACHE_NAME = 'offline-v1'; | |
const CACHE_NAMES = [STATIC_CACHE_NAME, APP_CACHE_NAME]; | |
const version = 'v1'; | |
// hard-coded list of app routes we want to preemptively cache | |
const routes = ['/']; |
NewerOlder