Should we be able to view a copied file in `bundle...
# help
d
Should we be able to view a copied file in
bundle copyFiles
LiveEdit/Dev mode for
sst.Function
?
Copy code
bundle: {
              copyFiles: [
                {
                  from: './eventSchema.js',
                  to: 'schemas/eventSchema.js',
                },
              ],
            },
This doesn’t seem to work for us…
Copy code
const getDirectories = (source: string) =>
  fs
    .readdirSync(source, { withFileTypes: true })
    .filter((dirent) => dirent.isDirectory())
    .map((dirent) => dirent.name)

const things = getDirectories(__dirname)
  console.log(things)
getting
[]
for directories
This works but it shows the root of my development machine… how does one get the root of where the file is running that works in both LiveEdit mode and when deploy to AWS.
@thdxr any thoughts?
f
Files currently aren’t copied in
sst start
mode. (something we are planning to make the behavior consistent with
sst deploy
)
t
yeah right now you have to structure things in a certain way or add an env variable for where to look that is conditional on app.local
it's a bit tricky to get this working right been considering some options
f
How are you referencing
eventSchema.js
? Possible to import it?
d
eventSchema.*json*
is a property of the EventAPI Custom Construct we created. At build time it uses ajv-cli to compile
eventSchema.*js*
and then SST bakes it into the
sst.Function
so it can use middy-ajv to validate the Lambdas inputs and/or outputs. Seems kinda helpful when you want to use HTTP-API for APIG which doesn’t support validation.