| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- import formatTimeToString from '../utils/formatTimeToString'
- const general = {
- timeFormats: {
- days: {
- 1: () => `day`,
- 2: () => `days`,
- },
- hours: {
- 1: () => `hour`,
- 2: () => `hours`,
- },
- minutes: {
- 1: () => `minute`,
- 2: () => `minutes`,
- },
- seconds: {
- 1: () => `second`,
- 2: () => `seconds`,
- },
- },
- functionWords: {
- and: () => `and`,
- },
- errors: {
- turnstile: {
- unavailable: () => `cannot connect to Turnstile. please try again.`,
- noToken: () => `Turnstile token was not provided. please try again.`,
- invalidResponse: () => `invalid Turnstile response. please try again.`,
- keyUsedOrExpired: () => `Turnstile key already used or expired. please try again.`
- },
- },
- }
- export default {
- emails: {
- auth: {
- subject: () => `login link`,
- text: (details) => `
- hi!
- you can login using the following code: ${details?.code}
- or the following link: ${details?.link}
- if you did not request this email, feel free to ignore it.
- meteostanica
- `,
- },
- },
- auth: {
- errors: {
- invalidEmail: () => `you need to provide a valid email.`,
- noVerificationToken: () => `verification token was not provided. please try again.`,
- verificationTokenUsedOrExpired: () => `verification token already used or expired. please try again.`,
- invalidVerificationCode: () => `invalid verification code. please try again.`,
- loginNeeded: () => `please log in first.`,
-
- ratelimits: {
- email: (details) => {
- if (!Number.parseInt(details?.duration)) return `too many requests for this email. try again later.`
- return `too many requests for this email. try again in ${formatTimeToString(general.timeFormats, general.functionWords.and(), details?.duration * 1000)}.`
- },
- ip: (details) => {
- if (!Number.parseInt(details?.duration)) return `you made too many requests. try again later.`
- return `you made too many requests. try again in ${formatTimeToString(general.timeFormats, general.functionWords.and(), details?.duration * 1000)}.`
- },
- code: () => `you entered too many wrong codes. you need to request a new verification.`,
- },
- turnstile: general.errors.turnstile,
- },
- },
- settings: {
- errors: {
- invalidEmail: () => `you need to provide a valid email.`,
- emailTaken: (details) => `a user with the provided email (${details?.newEmail}) already exists.`,
- turnstile: general.errors.turnstile,
- },
- },
- stations: {
- errors: {
- noName: () => `you need to provide a name.`,
- invalidOwner: () => `you need to provide a valid owner email.`,
- ownerUserNotFound: (details) => `a user with the provided email (${details?.newOwnerEmail}) does not exist.`,
- turnstile: general.errors.turnstile,
- },
- },
- websocket: {
- keepalive: () => `free ferris`,
- dataSaved: (details) => `successfully saved data for ${details?.meteostanica?.name}`,
- errors: {
- missingFields: () => `missing required fields: indoorTemp, indoorPressure, indoorHumidity, indoorAltitude, outdoorConnected, outdoorTemp, outdoorPressure, outdoorHumidity, outdoorAltitude`,
- invalidKey: (details) => `invalid station websocket key (${details.key}) provided`,
- },
- }
- }
|