Leke
Leke
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Leke on 7/18/2023 in #questions
AutoIncrement using mongoose
Please Guys what is the best way to implement AutoIncrement using mongoose, i tried the best two option and it wasnt working mongoose-sequence mongoose-auto-increment
const AutoIncrement = require('mongoose-sequence')(mongoose)

interface userTracks extends IUserTrack, mongoose.Document {}

const userModel = new mongoose.Schema(
{
fullName: {
type: String,
unique: false,
lowercase: true
},
email: {
type: String,
unique: true,
lowercase: true
},
phone: {
type: String
},
country: {
type: String,
unique: false,
lowercase: true
}
},
{ timestamps: true }
)

userModel.plugin(AutoIncrement, { inc_field: 'ticketNo', start_seq: 1000 })

export default mongoose.model<userTracks>('users', userModel)
const AutoIncrement = require('mongoose-sequence')(mongoose)

interface userTracks extends IUserTrack, mongoose.Document {}

const userModel = new mongoose.Schema(
{
fullName: {
type: String,
unique: false,
lowercase: true
},
email: {
type: String,
unique: true,
lowercase: true
},
phone: {
type: String
},
country: {
type: String,
unique: false,
lowercase: true
}
},
{ timestamps: true }
)

userModel.plugin(AutoIncrement, { inc_field: 'ticketNo', start_seq: 1000 })

export default mongoose.model<userTracks>('users', userModel)
3 replies
TTCTheo's Typesafe Cult
Created by Leke on 6/12/2023 in #questions
Attempted to load @next/swc-darwin-x64
I just created a new nextjs project and the first time i run the dev server i am seeing some errors in the console but the app running and i dont know if this will affect my project, please how do i resolve this issue?
> next dev

- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- info Using wasm build of next-swc
- warn Attempted to load @next/swc-darwin-x64, but an error occurred:
> next dev

- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- info Using wasm build of next-swc
- warn Attempted to load @next/swc-darwin-x64, but an error occurred:
1 replies
TTCTheo's Typesafe Cult
Created by Leke on 5/29/2023 in #questions
[vite-plugin-sass] Unexpected token u in JSON at position 0 error
I just migrated my react sass application from webpack to Vite but I haven’t been able to build since the migration took place. The error below is what I encounter
> vite build

vite v4.3.9 building for production...
125 modules transformed.
✓ built in 3.60s
[vite-plugin-sass] Unexpected token u in JSON at position 0
file: /Users/project/src/assets/css/sass/main.scss
error during build:
SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at Object.transformReducer (file:///Users//node_modules/rollup/dist/es/shared/node-entry.js:23567:81)
at file:///Users//node_modules/rollup/dist/es/shared/node-entry.js:24590:140
at async transform (file:///Users//node_modules/rollup/dist/es/shared/node-entry.js:23576:16)
at async ModuleLoader.addModuleSource (file:///Users//node_modules/rollup/dist/es/shared/node-entry.js:23782:30)
> vite build

vite v4.3.9 building for production...
125 modules transformed.
✓ built in 3.60s
[vite-plugin-sass] Unexpected token u in JSON at position 0
file: /Users/project/src/assets/css/sass/main.scss
error during build:
SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at Object.transformReducer (file:///Users//node_modules/rollup/dist/es/shared/node-entry.js:23567:81)
at file:///Users//node_modules/rollup/dist/es/shared/node-entry.js:24590:140
at async transform (file:///Users//node_modules/rollup/dist/es/shared/node-entry.js:23576:16)
at async ModuleLoader.addModuleSource (file:///Users//node_modules/rollup/dist/es/shared/node-entry.js:23782:30)
main.scss
@use "./_01_mixins.scss" as *;
@use "./_02_variables" as *;
@use "./_03_core.scss" as *;
@use "./_04_plugins.scss" as *;
@use "./_05_views.scss" as *;
@import url("https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&display=swap");

/** your custom css code **/
#root {
min-width: 320px;
}
.container-fluid {
max-width: 2000px;
}
.btn-link,
.btn-link:hover {
font-weight: 500 !important;
}
a.white:hover,
a.white:active {
color: $theme-color-1 !important;
}
label {
font-weight: 600 !important;
font-size: 90% !important;
}
a,
button,
input,
.sidebar .main-menu ul li a {
transition: color 0.5s, border 0.5s, background 0.5s, opacity 0.5s,
height 0.5s;
}
.sidebar .main-menu ul li a {
padding: 0 10px;
line-height: 1.2;
text-align: center;
}
.btn-primary {
color: #fff !important;
}
.has-float-label label {
z-index: 10000;
}
@use "./_01_mixins.scss" as *;
@use "./_02_variables" as *;
@use "./_03_core.scss" as *;
@use "./_04_plugins.scss" as *;
@use "./_05_views.scss" as *;
@import url("https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&display=swap");

/** your custom css code **/
#root {
min-width: 320px;
}
.container-fluid {
max-width: 2000px;
}
.btn-link,
.btn-link:hover {
font-weight: 500 !important;
}
a.white:hover,
a.white:active {
color: $theme-color-1 !important;
}
label {
font-weight: 600 !important;
font-size: 90% !important;
}
a,
button,
input,
.sidebar .main-menu ul li a {
transition: color 0.5s, border 0.5s, background 0.5s, opacity 0.5s,
height 0.5s;
}
.sidebar .main-menu ul li a {
padding: 0 10px;
line-height: 1.2;
text-align: center;
}
.btn-primary {
color: #fff !important;
}
.has-float-label label {
z-index: 10000;
}
3 replies
TTCTheo's Typesafe Cult
Created by Leke on 3/1/2023 in #questions
node-canvas error
node-canvas error
Is there any other library I can use since `node-canvas` seems to be an issue, please recommend.
Is there any other library I can use since `node-canvas` seems to be an issue, please recommend.
I tried using node-canvas with jsbarcode to process barcode from a node application but node-canvas seems to be an issue ever since I tried implementing using it.I have tried rebuilding from source yet the error still a blocker.
node:internal/modules/cjs/loader:1302
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: dlopen(/Users/mac/node_modules/canvas/build/Release/canvas.node, 1): Library not loaded: @loader_path/libpixman-1.0.42.2.dylib
Referenced from: /Users/mac/node_modules/canvas/build/Release/canvas.node
Reason: no suitable image found. Did find:
/Users/mac/node_modules/canvas/build/Release/libpixman-1.0.42.2.dylib: cannot load 'libpixman-1.0.42.2.dylib' (load command 0x80000034 is unknown)
/Users/mac/node_modules/canvas/build/Release/libpixman-1.0.42.2.dylib: cannot load 'libpixman-1.0.42.2.dylib' (load command 0x80000034 is unknown)

Node.js v18.13.0
[nodemon] app crashed - waiting for file changes before starting…
node:internal/modules/cjs/loader:1302
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: dlopen(/Users/mac/node_modules/canvas/build/Release/canvas.node, 1): Library not loaded: @loader_path/libpixman-1.0.42.2.dylib
Referenced from: /Users/mac/node_modules/canvas/build/Release/canvas.node
Reason: no suitable image found. Did find:
/Users/mac/node_modules/canvas/build/Release/libpixman-1.0.42.2.dylib: cannot load 'libpixman-1.0.42.2.dylib' (load command 0x80000034 is unknown)
/Users/mac/node_modules/canvas/build/Release/libpixman-1.0.42.2.dylib: cannot load 'libpixman-1.0.42.2.dylib' (load command 0x80000034 is unknown)

Node.js v18.13.0
[nodemon] app crashed - waiting for file changes before starting…
6 replies
TTCTheo's Typesafe Cult
Created by Leke on 2/22/2023 in #questions
Build failed due to import error
Build failed due to import error After running the build command for my react app the build failed and the below is the response I get.
Creating an optimized production build...
Failed to compile.

Attempted import error: 'LowPriority' is not exported from 'scheduler' (imported as 'LowPriority’).
Creating an optimized production build...
Failed to compile.

Attempted import error: 'LowPriority' is not exported from 'scheduler' (imported as 'LowPriority’).
package.json
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test"
},
An ideal on how to resolve this issue will be much appreciated.
2 replies
TTCTheo's Typesafe Cult
Created by Leke on 2/21/2023 in #questions
Auto select country flag when country code is provided
I am building a React project and it is required I implement a functionality that allow users to provide their phone number in an input tag with the country code and immediately the country code is provided then the flag of the country appears respectively. Is there a library I can use to achieve this or an API?
3 replies
TTCTheo's Typesafe Cult
Created by Leke on 2/8/2023 in #questions
SCSS Error: can not read files in public path
I have an assets folder that contain some other files with images and svgs in it in the public file of my project so... => navbar.scss ...I declared a variable with path below
$logo-path: "/assets/logos/black.svg”;
$logo-path: "/assets/logos/black.svg”;
Error: Module not found: Error: Can't resolve '../../../logos/mobile.jpg’
Failed to compile.

Module not found: Error: Can't resolve '../../../logos/mobile.jpg' in '/src/assets/css/sass/themes'
ERROR in ./src/assets/css/sass/themes/navbar.scss (./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].oneOf[7].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[0].oneOf[7].use[2]!./node_modules/resolve-url-loader/index.js??ruleSet[1].rules[0].oneOf[7].use[3]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[0].oneOf[7].use[4]!./src/assets/css/sass/themes/navbar.scss) 5:36-100
Module not found: Error: Can't resolve '../../../logos/mobile.jpg' in '/src/assets/css/sass/themes’
Failed to compile.

Module not found: Error: Can't resolve '../../../logos/mobile.jpg' in '/src/assets/css/sass/themes'
ERROR in ./src/assets/css/sass/themes/navbar.scss (./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].oneOf[7].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[0].oneOf[7].use[2]!./node_modules/resolve-url-loader/index.js??ruleSet[1].rules[0].oneOf[7].use[3]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[0].oneOf[7].use[4]!./src/assets/css/sass/themes/navbar.scss) 5:36-100
Module not found: Error: Can't resolve '../../../logos/mobile.jpg' in '/src/assets/css/sass/themes’
1 replies
TTCTheo's Typesafe Cult
Created by Leke on 2/8/2023 in #questions
`Cant install mongodb on mac`
28 replies
TTCTheo's Typesafe Cult
Created by Leke on 1/31/2023 in #questions
`window.scrollY` error `typescript`
3 replies
TTCTheo's Typesafe Cult
Created by Leke on 1/16/2023 in #questions
canvas.node
3 replies
TTCTheo's Typesafe Cult
Created by Leke on 11/30/2022 in #questions
How is option value string even after accepting a ``value={prop}`` of a number type?
1 replies
TTCTheo's Typesafe Cult
Created by Leke on 11/27/2022 in #questions
'paginationRange.length' is possibly 'undefined'.ts(18048)
4 replies
TTCTheo's Typesafe Cult
Created by Leke on 11/18/2022 in #questions
can i export data from reactQuery?
13 replies
TTCTheo's Typesafe Cult
Created by Leke on 11/10/2022 in #questions
React + Typescript...Its return type 'Element | undefined' is not a valid JSX element.
27 replies
TTCTheo's Typesafe Cult
Created by Leke on 11/4/2022 in #questions
React Typescript useContext( ) generic type
16 replies
TTCTheo's Typesafe Cult
Created by Leke on 11/4/2022 in #questions
React Typescript custom pageLayout
React Typescript pageLayout Hi everyone, I'm trying to achieve something and it seems very impossible with React && typescript. I have an application that has two header(s) at the top of every page, in this case the Login page takes Header1 and the dashboard page takes Header2, so the Header(s) depends on the page routing. Does anyone have an ideal on how to make this work ? I can also share what I have done as well for more clarity. Thank You. I have tried the same thing with just Nextjs and it worked but Typescript is making it look so hard.
1 replies
TTCTheo's Typesafe Cult
Created by Leke on 11/3/2022 in #questions
React Typescript SassError Undefined variable
18 replies
TTCTheo's Typesafe Cult
Created by Leke on 10/26/2022 in #questions
Typescript Property 'pull' does not exist on type 'ObjectId[ ]'
1 replies