JWT Token generation valid for 24 hours

Requirement is as follows-:

1)Need to create route at Kong Connect with version Kong Enterprise its a https endpoint that would generate JWT tokens valid for 24 hours post that after any request would hit the endpoint would be hit new JWT token would be generated

I followed the below approach created

1)Created pre-plugin containing lua script to generate and refresh JWT token after every 24 hours -Didn’t work Kong giving compilation errors

2)Created post plugin containing below lua script Kong giving compilation errors : module ‘kong.plugins.jwt.jwt’ not found:No LuaRocks module found for kong.plugins.jwt.jwt

Lua script
local jwt = require “kong.plugins.jwt.jwt”
local cjson = require(“cjson”)

– Define the JWT payload
local payload = {
iss = “”, – Passed here key
– sub = “user123”, – Subject (user identifier)
iat = ngx.time(), – Issued at (current timestamp)
exp = ngx.time() + 24 * 60 * 60, – Expiration (24 hours validity)

– Define the JWT secret key
local secret_key = “” //Passed here secret key

– Generate the JWT token
local token, err = jwt:sign(secret_key, {
header = { typ = “JWT”, alg = “HS256” }, – Header
payload = payload – Payload

if not token then
ngx.log(ngx.ERR, "Error creating JWT: ", err)

– Print the generated JWT token
ngx.say("Generated JWT token: ", token)

4)Also tried to upload lua scripts custom plugin in Kong Connect --Not Working

3)Post that created custom plugin inside custom folder on path /usr/local/share/lua/5.1/kong/plugins/ but not able to link that plugin to Kong Konnect Enterprise Version

Suggest me alternative approach so that I would be able to complete the requirement